Skip to content

How describe model for Record<string, string> TS type? #2003

Discussion options

You must be logged in to vote

Hey @KyryloSWAN - here's how I might model this out to start

const TopLevelObject = types
  .model("TopLevelObject", {
    some: types.array(types.frozen),
  });

It seems like the keys in each of your records are dynamic, and might not be suitable for "typing" in advance. In this case, the frozen type allows you to work with these objects, since they're serializable.

I do this from time to time when it comes with new third party APIs, where I'm not yet sure what data I'm going to really want or need to model out from them. We sometimes store JSON blobs as frozen types, until we can determine a better way to model the data that we expect to use from it.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@KyryloSWAN
Comment options

@KyryloSWAN
Comment options

@coolsoftwaretyler
Comment options

@KyryloSWAN
Comment options

Answer selected by KyryloSWAN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants