Avatar ·

How to create a key-value pair in TypeScript?

Hello everyone! I'm new to TypeScript, transitioning from JavaScript. In JS, I often used simple objects to store key-value pairs, for example: ```typescript const user = { name: "Anna", age: 30, city: "Moscow" }; ``` But now I want to create a more strict structure: I need to store dynamic data where keys and values can be of different types. For example, I'm writing a function that takes an array of key-value pairs and returns an object. In JavaScript, I would do it like this: ```javascript function buildObject(pairs) { const result = {}; for (const [key, value] of pairs) { result[key] = value; } return result; } ``` But TypeScript complains about `result[key] = value` if I don't specify types. I tried writing an interface: ```typescript interface