import { type MethodOf } from "https://deno.land/x/drash@v3.0.0-beta.2/src/core/Types.ts";
A utility type that lets the compiler and reader know: the member
assigned this type is a method of the given generic Object
.
Examples
Example 1
Example 1
class One {
a() {}
b() {}
c() {}
}
const methods = ["a", "b", "c"];
const one = new One();
one[methods[0]]();
// Element implicitly has an 'any' type because expression of type 'string'
// can't be used to index type 'One'.(7053)
one[methods[0] as MethodOf<One>]();
// OK