How can I make sure two arrays contain the same keys (in seperate files)
I'd like typescript to spit an error if I update one array, but not the other.
I'm using T3 stack.
So far all I have is:
This should throw an error because const styles: StylePrompt[] is missing solid and duotone
3 Replies
I would create a shared file that exports the styles array and import it into any file that needs them
if they are also related that closely, I would combine them and include the
prompt
key in the original style array. They already share the same id
, etc.Solution
You could also consume these objects using a zod schema to do the parsing
If it’s third party data it wouldn’t be a bad idea to set this up