sven
07/23/2021, 9:47 AMsven
07/23/2021, 9:52 AMmodel ActivityA {
id String @id
text String
}
model ActivityB {
id String @id
image String
}
my typeGuards look like:
const isActivityA = (data?: any): data is ActivityA => !!data && 'text' in data;
const isActivityB = (data?: any): data is ActivityB => !!data && 'image' in data;
This works, but can get a little error prone: Imagine one would add ActivityC that has both text and image.
I wonder if there is a helper function or something that can help with that?Pierre Ortega
07/23/2021, 3:45 PM