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
I was pondering upon the old "dynamic keys" extraction problem recently and I had an idea that I think might work, but I have nowhere near enough knowledge or experience with either TS API or Babel plugins to be sure, so I'll just put this up here and perhaps someone can shed more light on it.
It is clear why extracting entirely dynamic keys as in
cannot work. However, if we are very strict about the type of key - which in my experience is often the case, and most of the time can be achieved in a healthy codebase - I think perhaps the extractor could actually infer all possible variations? E.g.
If this were possible, I think it may solve many, if not most of the existing "I want to extract dynamic keys" problems, at least for strict Typescript users. In the codebase I work on, this is actually 100% of cases with interpolated message IDs.
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
Uh oh!
There was an error while loading. Please reload this page.
-
I was pondering upon the old "dynamic keys" extraction problem recently and I had an idea that I think might work, but I have nowhere near enough knowledge or experience with either TS API or Babel plugins to be sure, so I'll just put this up here and perhaps someone can shed more light on it.
It is clear why extracting entirely dynamic keys as in
cannot work. However, if we are very strict about the type of
key
- which in my experience is often the case, and most of the time can be achieved in a healthy codebase - I think perhaps the extractor could actually infer all possible variations? E.g.could actually generate all of
If this were possible, I think it may solve many, if not most of the existing "I want to extract dynamic keys" problems, at least for strict Typescript users. In the codebase I work on, this is actually 100% of cases with interpolated message IDs.
Beta Was this translation helpful? Give feedback.
All reactions