Hi there, this library makes AST magic much easier to understand :-) But for beginners like me there are still some blind spots in the documentation.
For example after reading the docs I can't see the difference between saving and emitting? Both seem to commit current node tree to the file system/memory?
Cheers
Saving saves the changes you made to the source TypeScript files you made. For example, you can create a new TypeScript file foo.ts and write some text in it. When you hit project.save() (and the promise resolves), a new file will be create on your disk with the contents you specified in your manipulation code. Before you hit .save(), the new "file" only exists in the memory of the currently running (it's not persisted on the disk).
Emitting is much like compiling an exiting TypeScript project to JavaScript when you run tsc from the command line. It will look at the current state of the TypeScript project and create necessary .js and/or .d.ts (depending on the options).
So yes, in a sense, they both write to the disk (by default), but they write different files for different purposes. Hope this clears things up!
So, saving is updating/creating .ts files, and emitting is creating compiled .js files? Got it, thanx
Yup! Thanks for answering this @lazarljubenovic!
Also, sorry this wasn't clear @mi5ha. I just did a commit to update the docs for this and I will merge that to master soon. I need to spend a lot more time updating the documentation.
Most helpful comment
Yup! Thanks for answering this @lazarljubenovic!
Also, sorry this wasn't clear @mi5ha. I just did a commit to update the docs for this and I will merge that to master soon. I need to spend a lot more time updating the documentation.