I have a helper class with some static methods:
export default class MyHelper {
private constructor() {}
private static privateMethod() {}
public static publicHelperMethod() {}
}
I have a React component that uses publicHelperMethod and I want to ensure that this specific method is passed in my props declaration.
The way I have attempted to this is:
type LoggerMethod = MyHelper.publicHelperMethod;
But this throws an error and says MyHelper is being used as a namespace.
I can make the class itself a type:
type Helper = MyHelper;
But I'm only interested in my logger method (the public helper in this abstraction).
Is it possible to make a method of a class a type? If so, what is the syntax for this?
Or, am I going about this entirely the wrong way?
sorterinterface that takes two values and returns a number, butfunction multiply(a, b) { return a * b }also matches that signature, yet it isn't fit for sorting. So, it's not like the function interface solves your type problems.() => void, or maybe(this: typeof MyHelper) => void, but there's no way to represent a particular function of that type. That is, there are no "function literal" types.