Exporting a function on typescript "declaration or statement expected"

I realize this is really simple but typescript seems to have changed a lot in the last years and i just cant get this done with previous answers i found here on stack overflow.

let myfunction = something that returns a function

export myfunction;

I get an error "declaration or statement expected"

How can i export a function from a really simple ts file to be able to use the function in another ts file?


Solution 1:

It seems that

let myfunction = something that returns a function
export {myfunction};

will do the trick.

Solution 2:

Use

export default myfunction

if you only have this function to export from this file. Otherwise use

export { myfunction, <other exports> }

to export myfunction along with other types to export