This is an example project that represents how to set up a Node.js ES6 module project with Jasmine@4 for TypeScript.
Key steps:
- add
@types/jasmine
andts-node
to the dev dependencies$ npm i --save-dev @types/jasmine ts-node
- set
"type": "module"
in thepackage.json
- set the
NODE_OPTIONS=--loader=ts-node/esm
environment variable before run jasmine. - use
.js
file extension in Typescript relative import because ES6 import requires the full path BUT Typescript does not override or change the import path when transpile the code, or support*.ts
extension so.js
has to be used. You can read about more here, here or here