Answer the question
In order to leave comments, you need to log in
How to set up adequate transpiling in ES6 (for Node.js) from TypeScript?
Hello! I’m sad here - I’ve been fiddling with the transpiling settings from typescript to JS (ES6) for Node.js 0.12 for a day and a half (the oracle driver does not work with version 4 yet)
I start the Node with the --harmony flag, which gives me partial support for es6, in particular generators are needed.
However, such things as "import .. from .. / export" the node still does not know how, considers this to be foul language. Namely, in this form, import-export of modules in JS is squeezed out of TS! And I can't influence it in any way.
In 4.2.1 version of the node, by the way, the same problem.
As for TypeScript, I tried to set it up in different ways. Of course, --target is ES6 , the --module flag is invalid in "ES6" mode, and moduleResolutiontried both "classic" and "node". The last parameter I don’t really understand why, but I tried it just in case.
And how does it happen that TypeScript transpiles into node JS what the node cannot interpret? And in general, is it possible to make it so that I can use the full syntax and features of TS, while getting valid js code that is suitable for a node?
Answer the question
In order to leave comments, you need to log in
Well, as if in ES6 mode, the remaining modules are not needed, so it --module
does not work, which is logical. It is simply stupid to think that ES6 code is suitable for 0.12 (there is no such thing as this support), io.js appeared at one time precisely for this reason.
Compile to ES5. 0.12 doesn't support ES6, period . Or use ts-node .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question