-
-
Notifications
You must be signed in to change notification settings - Fork 293
Support createMessagesDeclaration
for pages router
#1832
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
Comments
Hmm, that's a fair point. To add to this, also apps that use the core library In an ideal world, the TypeScript team would address microsoft/TypeScript#32063, which would make the need for this entirely obsolete. But despite the popularity of the request, it doesn't look like anything is moving in that issue currently. The next-intl/packages/next-intl/src/plugin/createMessagesDeclaration.tsx Lines 65 to 71 in 3192ca1
Additionally, in development a watcher is started: next-intl/packages/next-intl/src/plugin/createMessagesDeclaration.tsx Lines 38 to 42 in 3192ca1
We could of course offer a standalone CLI, but it would increase the API surface for something I'd like to get rid of at some point anyway. Another option that would come to my mind for your particular case is that we could allow to set Might need to think a bit more about this—I wonder if there's another solution. /cc @stefanprobst I think you asked for something similar.
Thank you so much! ❤ |
i am currently just calling // scripts/generate-i18n-message-types.ts
import createI18nPlugin from "next-intl/plugin";
createI18nPlugin({
experimental: {
createMessagesDeclaration: ["./messages/en.json"],
},
})();
console.log("Successfully generated i18n message types."); and {
"scripts": {
"prepare": "tsx ./scripts/generate-i18n-message-types.ts"
}
} |
Sweet, this workaround suits me also - thanks @stefanprobst! |
This issue has been automatically closed because there was no recent activity and it was marked as unconfirmed. Note that issues are regularly checked and if they remain in unconfirmed state, they might miss information required to be actionable or are potentially out-of-scope. If you'd like to discuss this topic further, feel free to open a discussion instead. |
Is your feature request related to a problem? Please describe.
With the v4 release of
next-intl
, type-safe message arguments is now possible, which is a very exciting prospect for closing one of the last loosely-typed gaps in our application!However, the existing documentation around the feature suggests it is an experimental behaviour exposed only to the app router implementation, as it needs to be set in the
createNextIntlPlugin
config blob, which is not utilised by the pages router, and which throws if called by a page-routed app.I appreciate that this behaviour is currently only experimental, but it would be awesome if it could be exposed for those of us using the pages router too - especially given Vercel plans to continue support for the pages router in Next.js "for many years in the future"!
Describe the solution you'd like
Exposing the
createMessagesDeclaration
utility such that it can be called in the Next.js config file to generate the declaration file would be great - or really any other way of exposing this functionality to page router implementers.Describe alternatives you've considered
PS. Loving
next-intl
- thanks for all the work you've put in to make it as awesome as it is! 🙂The text was updated successfully, but these errors were encountered: