I am a typescript newbie. I don't know how to reference (import) a module in a script
In my index.html
file I am referencing
<script src="main.js"></script>
and in the main.ts
file I am trying to import another typescrtipt module
import greet from './greeter';
greet();
and in the greeter.ts
file I am exporting a function
export default function greet(): void {
console.log('Hello World');
}
But in the browser console I see an error that says Uncaught ReferenceError: exports is not defined
Here's my tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}
I tried changing the "module"
property to "es2015"
but it does not work.