Extend LocalizedString type to allow empty string #676
Closed
maxpatiiuk
started this conversation in
DX improvements
Replies: 1 comment 1 reply
-
|
Hi @maxxxxxdlp, thanks for your suggestion, but I prefer not to do so. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Would it be possible to make LocalizedString typescript type that is provided by this library consider an empty string to be localized?
Example implementation
That might look like the following:
Benefits
Empty string is often used as a placeholder/default value for a place that will store localized string.
Workarounds
So far I created a
declarations.d.tsfile like this to overwrite the type exported by this library:Unfortunately, not every tool supports declarations file (ts-node requires extra options, typescript-eslint has some weirdnesses; my co-workers reported problems in vs code too - the above fix doesn't work for them, even though tsc is fine with it)
Drawbacks
There are cases where TypeScript may expand
''to meanstring, thus negating the benefit ofLocalizedStringtype.Beta Was this translation helpful? Give feedback.
All reactions