You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first suggestion is more idiomatic with all other methods having orThrow variants. The second suggestion is semantically even different, how would you distinguish the case when you successfully added a source file and the case when you did not because the file did not exist?
Anyways this looks like a simple issue to start contributing with, I'd like to take a look at it once the TODO is done.
@ChristianIvicevic yeah, it is more more consistent... I just feel I like the IfExists a bit more in this scenario for the following reasons:
When people use this method they will 99% of the time use the one that always returns a source file (the one that throws). I'd prefer the shorter method name to be the common one and the one to lead people to use.
It's not as clear in this scenario why it throws. Does it throw because something is wrong with parsing? Someone would have to read the JS docs to find out. The IfExists suffix is pretty clear though.
So I know it's inconsistent, but I think the inconsistency is ok here. I've also been playing around with both and I feel like I like the addSourceFileAtPath/addSourceFileAtPathIfExists a bit better.
Sure, that would be great! If you'd like to contribute this is pretty easy. Basically:
Follow them out to where they're used in Project and Directory.
For each method in the public api, create a new method with the new name and then on the old method add a @deprecated jsdoc tag saying what the new name is (don't delete it... just point the old method to the new one).
I always didn't like this method name. Just thought of this which I think is better.
This should be a soft rename for a long time to allow people ample time to switch.
Would also be nice to have code mods for these changes...
Todo: Consider either
addSourceFileAtPath/addSourceFileAtPathOrThrow
oraddSourceFileAtPath/addSourceFileAtPathIfExists
. ProbablyIfExists
is better.The text was updated successfully, but these errors were encountered: