-
Notifications
You must be signed in to change notification settings - Fork 264
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
Release of v3.0.0 #184
Comments
Any news on this? Please let me know if anyone needs any help moving this forward, I'm happy to help. |
We're thinking about pushing the canary to stable - have y'all been able to use the canary okay without any issues? |
Yes, the canary release works great. Only downside is that the plain |
The whole usecase of |
String looks like it is still accepted. I'm using strings on the canary build right now. They added StringValue to 3.0, and the documentation essentially recommends wrapping the ms() function with another function that has typed input for type safety. https://github.com/vercel/ms/tree/3.0.0-canary.1#typescript-support |
Maybe I've overlooked something obvious, but it seems to me that const foo: string = '10s'
ms(foo) "TS2769: No overload matches this call." Wrapping the function as suggested by docs would be an okay solution, if in fact Lines 93 to 95 in 1304f15
This means the type safety via try-catch is simply an illusion. Moreover, I couldn't find this behavior documented anywhere. We'd have to use something like: function ms2 (value: string): number | undefined {
try {
const parsed = ms(value as StringValue)
if (Number.isNaN(parsed)) {
return undefined
}
return parsed
} catch (error) {
return undefined
}
} which is quite a bit of boilerplate to include in every project, just for ms. |
I confirm that string is no longer accepted, which is unfortunate. |
Ah oops, my mistake. I went back and double checked the typings and reread the documentation. You could just wrap the ms function with another and use it if you're going to use it in a lot of places:
They show this in the docs too. Behavior looks like it should still be same as the current version where an error gets thrown with bad input. |
That's true, the behavior is unchanged since the previous version. No error gets thrown in case the input string fails to parse, though (see my previous comment). This means your proposed solution is unfortunately unsafe. See also #123. |
If there's gonna be a major version bump, can we change One genuine helpful case for this is that I sometimes can't tell if |
very stable here... |
Friendly bump! Canary has been working perfectly ever since it was released... I recommend pushing to stable :) |
Just ship it! 😄 |
What is needed to finish for a stable version? I am ready to help |
@leerob With all due respect, I don't think people will adopt Even issue #189 demonstrates, how easily people miss the notice in the README, and as such don't install |
@meyfa, we're open to PRs if you have an implementation in mind! We can always ship incremental improvements as minor updates too. Here are some alternatives: // 1. Cast to `StringValue`.
import ms, { type StringValue } from 'ms';
ms(someVar as StringValue);
// 2. Use `StringValue` in your code.
import { type StringValue as MsStringValue } from 'ms';
interface MyArgs {
time: MsStringValue
}
// 3. Build a small wrapper.
import ms, { type StringValue } from 'ms';
export function stringMs (str: string): number {
return ms(str as StringValue);
} |
In my opinion, a stable version of v3 should include #191. It would also be nice to get a published version of this change. |
hey @leerob, it's been more than a year and a half since you said this, any updates on why it hasn't been published yet? it looks very stable |
hey @styfle, you seem to be one of the only active members of the repo as of right now, do you have any updates on the status of v3? see the comments above |
For anyone still interested, a little update here: |
Hello, I think it's quite awesome that this package is now written in TypeScript! Since it's been over half a year since the last v3 canary, I would like to ask whether a final release is planned yet.
The text was updated successfully, but these errors were encountered: