After a quick search, I've found that apparently this option was considered for some operations but not for all, such as save and saveSync. It would be nice if we could overwrite when saving a file.
Seems to me like I have to manually delete the file, maybe there's another way?
Can you post a short snippet of code that shows the problem? It should be overwriting.
Oh? It tells me:
/home/lazar/ts-ast/node_modules/ts-simple-ast/dist/factories/CompilerFactory.js:154
throw new errors.InvalidOperationError(prefixMessage + "A source file already exists at the provided file path: " + filePath);
^
Error: A source file already exists at the provided file path: /home/lazar/ts-ast/demo2-counter/compiled/RootPageComponent.factory.js
I'm just creating a file, writing a function into it and then saving it with saveAsync. I'll create a full repro tonight.
Oh ok. That makes sense. That error happens on createSourceFile (not on save).
I鈥檒l think about this... probably will add an options object as the third parameter.
Oh, I didn't even notice where it happens. Sorry for the confusion and thanks! :sweat_smile:
This will be in the next release (tomorrow evening probably Edit: Nevermind, need to finish the other issues in the version 10 milestone... sometime this week or next).
const sourceFile = project.createSourceFile("/file.ts", "", { overwrite: true });
In the future, there will probably be more options.
This is available now in 10.0.1.
Most helpful comment
This is available now in 10.0.1.