Is there a way to create a strict typeGuard functi...
# prisma-client
s
Is there a way to create a strict typeGuard function other than writing it by hand?
Example:
Copy code
model ActivityA {
  id    String @id
  text  String
}

model ActivityB {
  id    String @id
  image String
}
my typeGuards look like:
Copy code
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?
p
Not on current typescript version, but there will be on Typescript 4.4