We use a module that does not export the type of all its parameters. This means that the arguments are checked by typecheck, but we cannot determine the variable of the required type before calling the method.
Example:
interface Internal { foo(): number }
class A {
bar(s: string, x: Internal): string {
return s + x.foo();
}
}
export const Exported = A;
When using, Exported.baris there any way for me to first define an argument so that it types correctly?
let e = new Exported();
let x : ;
e.bar("any ideas?", x);
I was thinking of a way to use generics to create a nulltype Internal, so I can give the xcorrect type, but it's very awkward, is there a way to capture this type in the typedefinition and use it more cleanly?
function deduce<T>(f: (s: string, t: T) => any): T {
return null;
}
let x = deduce(e.bar);
source
share