there are some ways to model inheritance with rescript type systems, sometimes it’s worth it, sometimes it’s just too cumbersome, so you can try and judge by yourself!
Here is an example (try it in the playground):
type vehicule<'kind>
type car<'model> = vehicule<[#car]>
type ferrari = car<[#ferrari]>
type bike = vehicule<[#bike]>
@get external getName: vehicule<'kind> => string = "name"
@send external openTrunk: car<'model> => unit = "openTrunk"
@send external goVeryFast: ferrari => unit = "goVeryFast"
@val external myBike: bike = "myBike"
@val external myFerrari: ferrari = "myFerrari"
myBike->getName->Console.log // this works
myFerrari->getName->Console.log // this works too
myBike->openTrunk
/* ^
Error:
This has type: bike (defined as vehicule<[#bike]>)
But this function argument is expecting:
car<'a> (defined as vehicule<[#car]>)
These two variant types have no intersection
*/