TypeScript Exports Module for Node.js

Thu Sep 01 2022

Long Story Short

TypeScript
|
const func = () => { console.log('Hello World'); } // Export for TypeScript module system export default func; // Export for Node.js module system, by doing this you can use `require` to import the module in Node.js if (typeof module !== 'undefined') { module.exports = Object.assign(func, module.exports) }