i need to extend a prototype, creating methods by mapping a set of strings into a single function. however, i'm having trouble extending a class prototype even for a base case. e.g.:
class Hello {}
Hello.prototype['whatever'] = 1
// [ts] Element implicitly has an 'any' type because type 'Hello' has no index signature.
i read here about index signatures, but not sure how to extend the prototype's definition?
really, i want something pretty simple, similar to as follows:
const methods = ['a', 'b', 'c']
const exampleMethodImplementation = () => 'weeee'
class Hello {
x: number
}
methods.forEach(name => { Hello.prototype[name] = exampleMethodImplementation })