I have successfully exported a function in the following way:
module.exports = function (options: any): RequestHandler {
// Do something
}
Now, I am attempting to define the exported function properly. However, I am unsure if this is the correct approach:
declare global {
export function tsm(options: any): RequestHandler
}
While testing, both of the following methods indicate that it is valid:
const tsm = require('ts-middleware')
global.tsm() // Provides intellisense
tsm() // Also provides intellisense
The fact that global.tsm()
is being recognized leads me to believe that my definition may be incorrect. How can I create a proper function definition?
I prefer not to use the function like this:
const tsm = require('ts-middleware')
tsm.tsm()
Instead, I would like to use it like this:
const tsm = require('ts-middleware')
tsm()