-
-
Notifications
You must be signed in to change notification settings - Fork 210
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
feat: Typesafe Global Formats #1346
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@dBianchii is attempting to deploy a commit to the next-intl Team on Vercel. A member of the Team first needs to authorize it. |
Hi @ amann/maintainers You said in here that the package supports You also said:
I haven't found this logic in the code, and also in my tests when I do Could you explain a bit more of what you meant? EDIT: Looks like that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damn you're quick! 🔥🔥
I somehow left this feature on the backlog for a long time, but you made it happen just over night! 😄 Super cool, thanks a lot!
I've left a few comments inline, let me know what you think!
Btw. regarding the defaults across usage in messages / via format.*
: You're absolutely right, I've opened #1347 as a separate issue to discuss this. This is definitely out of scope for this PR and type-safety is only relevant for format.*
calls, therefore we should assume no defaults there.
There is one problem with this right now: I see that the global format api has been designed to be able to handle global formats for client and server differently/separately. (We must provide formats to both How can we resolve this problem? |
Yep, I agree! The discussion is related to the one about messages: Messages are defined globally, but it's the user's job to provide the relevant messages where relevant. This is to allow the user to optionally pass only certain messages to the client side to optimize bundle size, which is also the reason why the The current state of the library has the same mechanism for That being said, I think it's fine to model Hope that sounds reasonable to you! |
That's awesome to hear. Makes total sense to me. I'll continue with this decision in mind. Thanks! |
Ok, so I added a few tests to Please let me know if you think that this implementation is good enough, or if there could be something missing/edge cases. Whenever you think all is good, I'll go ahead and start working on the docs. I have to say I'm very impressed with the documentation on this project. I'll do my best to follow suit and try to explain things in the best manner possible. |
1. Add comment for type safe formats in `example-app-router-playground` 2. No need to execute type tests in `ClientContent` 3. A few more tests for `useFormatter` when no strict types are supplied
Looks awesome, thanks a lot! I had another look over the changed files and cleaned up a few minor things along the way and added some more tests for the case when no strict formats are supplied: 3fa91e8. Hope that's ok for you! I think the implementation is solid now! 💯 You wanna give the docs a shot? 🙂 Means a lot to me if you like them! 😊 |
Ready to go. Please check though: I don't know why but I am getting some problems running I noticed I accidentally pushed a bunch pnpm lockfile changes, so I tried to use the correct pnpm version to revert it but no luck in running the installer. Feel free to make any further changes |
This PR adds a new configuration called
IntlFormats
, where users can link their global formatting to this interface, and allow for global formats typesafety to work across their app.TODO
Closes #1112