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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
make return type of t
a branded type like TranslatedString
rather than plain string to aid type safety
#2028
Comments
I looked at that before posting, i think it's a different thing? that seems to be related to accepting the |
This is a good idea, but might be an even bigger breaking change than mine was 馃槄 |
haha yes, very possible it would be. wondering if it could be opt-in behavior, via config or via a new |
Yes, I鈥檓 sure you could make it opt-in via CustomTypeOptions or something like that. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Don't close please :) |
馃殌 Feature Proposal
It would be useful if the
t
function returned a branded type, rather than a plain string, so that you can enforce at a type level that a function/component/other is receiving a translated string.Motivation
Consider you have a function
showToast
which can be called from anywhere in the app to show a message to the user e.g.in the ideal, all strings passed to it have been translated:
but there is nothing stopping you from doing:
this will produce no errors, and can only be caught through ongoing diligence and manual review. as such, this is error prone.
It would be useful if the
t
function returned a branded type likeExample
with a branded type you can enforce via the type system that untranslated strings are not propagating through the system:
The text was updated successfully, but these errors were encountered: