Say I have this module foo with the methods bar and baz:
function foo(){
function bar() {}
function baz() {}
return { bar, baz }
}
I want to define the type of the returned object so that I can import it into different files. But @typedefs can only be imported if they're in the file's outer scope.
Here's an approach that 'works' in achieving the desired result but potentially not resilient to certain types of module implementations.
function foo(){
function bar() {}
function baz() {}
return { bar, baz }
}
let type = foo() // Create a arbitrary instance
/** @typedef {type} foo */
Is there an intentional way of defining the type of module interface objects?
Also, I don't find manually writing a typedef for the whole object in the outer-scope a good solution since the documentation is already written once at each method.