Typescript offers great safety against data corruption, it verifies every part of the data flow in your app and compares it against the libraries signature.
If anything seems wrong, it asks you to double check at compile time.
Then is there any tip to get them both until typescript gets full ecmascript modules support ?
The answer is ‘maybe’, but you will need the typescript transformer library (ttypescript).
Follow these steps and you will be able to use them :
1. add ttypescript and renamer to your application : `yarn add ttypescript renamer -D` or `npm install ttypescript –save-dev`.
2. in addition to your tsconfig.json, add a new file called `tsconfig.esmodules.json` and write the following :
3. Then create a file called “add-mjs-extension-transformer.js” and paste in the content from https://gist.github.com/libetl/beab668e10599f67d4dba1c75e825931
4. Go to your package.json, add a script to build your project with ttypescript and add an extra step to automatically rename all the .js files into .mjs files :
5. From now on, your typescript project will build ecmascript modules with the command npm run build:esm ; the below is how your published mjs files will look like :