-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path: [email protected] breaks compatibility with previous versions #1215
Comments
/cc @cjihrig |
Looking. |
The case for |
I don't have a strong opinion on this and am tempted to call out those relying on edge-cases to fix bugs in their own code, but perhaps that's not very community-friendly of us and we should just be paving cowpaths! |
Alternative here is to print a deprecation warning on anything other than strings, that might be the gentle way to proceed. I honestly can't make sense of |
+1 for deprecation warning |
The array use case is weird – agreed. I have no idea how/why that was working before.
|
Ah, I figured out why the array parameter was working: > path.dirname([ 'sup/dude', 'sup2/dude2' ])
'sup/dude,sup2' The array was being I still think we should consider making |
Some functions flat out break if a string isn't passed. I'm trying to identify those, and will remove the check from the others. |
I'll put this in the 1.6.1 bucket if we can get it done today, is that reasonable @cjihrig? |
Coming in a few minutes. |
I'm more in the camp of not supporting weird usage like This strongly reminds me of JS type coercion. Sometimes it's better to crash and burn, than to silently try to do the right thing™. |
I agree with @silverwind. Special behavior on |
FWIW, I agree completely. Making the APIs more restrictive cuts back on JavaScript wats. But, it is what it is. |
I also agree with @silverwind - but the behavior should remain consistent for now. Maybe add it as a discussion in the next meeting? |
cc @substack |
FWIW all string-accepting web APIs and built-in ES APIs to ToString on their arguments, instead of type-testing. I am surprised io.js is trying to break with that; it violates my expectations. |
Breaking working npm packages is not cool, even if it's the right API decision for iojs. If we're going to make an API more restrictive in the inputs it accepts, we should strive to have a deprecation notice for a while first. As Rod says, it's the gentler way to proceed and nicer to users :) |
a465840 added strict type checking for the methods in the path module. However, dirname(), basename(), and extname() actually had some undocumented uses in the wild. This commit loosens the type checking on those methods. Fixes: #1215 PR-URL: #1216 Reviewed-By: Rod Vagg <[email protected]>
Fixed in 8de78e4 |
Let me know if you're still having problems. |
Thanks! |
What you're saying is right, it's just it doesn't apply to this situation On Thu, Mar 19, 2015 at 6:04 PM, Domenic Denicola [email protected]
|
I have seen such a language, it's called JavaScript. It's very nice and much code depends on it. |
We still ❤️ Brendan for this lovely coercion feature. |
Just a wild thought, but why not turn a bug into a feature? var folder = 'abc'
path.dirname(['some', folder, 'path'])
// some/abc/path The currently reported case would remain valid, and array with more than one value would now also work. Thoughts? Stupid or a good idea? |
iojs shouldn't break existing code this easily. It'd be better to provide type annotations to avoid such usage at compile time (eg: Flow, TypeScript) moving forward. This is also a more elegant way to trigger warnings of deprecation than And of course, most importantly, it wouldn't break existing code. |
krakenjs/localizr was broken by this too, surprisingly! |
In iojs 1.5.1:
In iojs 1.6.0:
This appears to be a bug introduced by this PR: #1153.
This suddenly started causing tests in
webtorrent
andbrowserify
to start failing. Here's an example.The text was updated successfully, but these errors were encountered: