I am trying to use flow-remove-types to remove types from node scripts before running them. I tried the following: node -r esm -r flow-remove-types/register index.mjs. This fails at type annotations. Is this an issue with this package or with flow-remove-types?
Does this work for you?
node -r flow-remove-types/register -r esm index.mjs
No, I still get this error:
file:///typeHelper.mjs
export const isArray = (value: any): boolean %checks => {
^
SyntaxError: Invalid or unexpected token
Does it work with .js?
Yes :o If I change all imported files to js then it works. Is this an issue with esm or with flow-remove-types? And do you know what's missing? Thanks!
Ping! @TrySound why did you ask if it only works with .js? I still need a solution since changing all files to .js in the repo I am working on is not really realistic.
Both tools support mjs. I don't know what is the problem. But using mjs for source code was not a good idea :)
I couldn't figure this out so I ended up changing the extensions of my files to .js and I switched from esm to @babel/node which fits my use case a lot better anyway.
The docs state that .mjs is restricted (no esm options or extra functionality extend to it).
Since ES module support was experimental in Node the functionality we extend to .js is not covered by .mjs.
Most helpful comment
Does it work with
.js?