Complete the code to declare an index signature for a dynamic key in a TypeScript interface.
interface UserData {
[[1]: string]: number;
}The index signature uses a variable name (commonly key) to represent dynamic keys of type string.
Complete the code to specify the type of values for the dynamic keys in the interface.
interface Settings {
[key: string]: [1];
}The index signature defines that all dynamic keys have values of type string.
Fix the error in the index signature declaration to allow dynamic keys with number values.
interface Scores {
[key: [1]]: number;
}number as key type without understanding how keys are coerced to strings.boolean for keys.Index signatures for dynamic keys must use string or number as key types, but string is preferred for object keys.
Fill both blanks to declare an interface with dynamic keys of type string and values of type boolean.
interface Flags {
[[1]: [2]]: boolean;
}The index signature uses a variable name (like key) of type string to represent dynamic keys with boolean values.
Fill all three blanks to declare an interface with dynamic keys of type number and values of type string, using a variable named 'id'.
interface DataMap {
[[1]: [2]]: [3];
}The index signature uses id as the variable name, number as the key type, and string as the value type.