Can you show me how to create a dynamic interface like this:
const fn = (v: string) => console.log(v)
class Methods {
a: fn
b: fn
}
using literal type definitions for keys?
type Keys = 'a' | 'b'
const KeysList = ['a', 'b']
Maybe something along the lines of:
const fn = (v: string) => console.log(v)
class Methods {
[key in Keys] = fn
}
new Methods().a("example")
The idea is to minimize code repetition by providing a more concise way to define multiple keys with the same functionality.