xxxxxxxxxx
let myObjHavingStringKeyAndStringValue : {[key: string]: string}
xxxxxxxxxx
interface MyObject {
[key: string]: any;
}
// Usage example:
const myObject: MyObject = {
key1: "value1",
key2: "value2",
};
// Accessing values
console.log(myObject.key1); // Output: "value1"
console.log(myObject.key2); // Output: "value2"
xxxxxxxxxx
Even if you do this:
const a: Record<number, string> = { 1: 'foo', 2: 'bar' }
Type of keys are not number:
typeof Object.keys(a)[0] == "string"
typeof Object.keys(a)[1] == "string"
You have to use map.