I recently discovered that you can do this in JS:
function foo() {
console.log("FOO");
}
foo.bar = "FOOBAR";
foo(); // logs "FOO"
console.log(foo.bar); // "FOOBAR"
Now my question is: How can I express this kind of object/function in typescript, e.g. when passing it to another function as a parameter?
This obviously throws an error...
type Foo = () => void;
function test(foo: Foo) {
console.log(foo.bar); // Property 'bar' does not exist on type '() => void'.ts(2339)
}
Any ideas other than declaring it as an any?