You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far I have a great fun using new v9.2.x release - specifically the TypeScript improvements
I have a question (or suggestion)
I was trying to define a TS type, that would be a replacement for a string type for my app internal API's that receive a translation key and sometimes later they call a Vue-i18n function (such as t) on it. Just to enjoy better intellisense and type safety
So far I got this:
importtype{PickupPaths}from'vue-i18n'// Messages is a type of all my i18n jsonexporttypeMessageKey=PickupPaths<Messages>
This works pretty well. Probably only quirk is it accepts "partial path" - like a have a "validation" key with many subkeys one level down and it accepts "validation" (which is an object and not a translation key).
Is there better way ? It would be great if something like that would be "official TS API" and documented..
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
So far I have a great fun using new v9.2.x release - specifically the TypeScript improvements
I have a question (or suggestion)
I was trying to define a TS type, that would be a replacement for a
string
type for my app internal API's that receive a translation key and sometimes later they call a Vue-i18n function (such ast
) on it. Just to enjoy better intellisense and type safetySo far I got this:
This works pretty well. Probably only quirk is it accepts "partial path" - like a have a "validation" key with many subkeys one level down and it accepts "validation" (which is an object and not a translation key).
Is there better way ? It would be great if something like that would be "official TS API" and documented..
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions