Played around with this a bit more and I am able to get a similar error if I’m not using the generic prop inside of my component. It goes away once used. Please share if you have a case where it’s used and you still see the error.
The ReScript compiler is very conservative when you have generic values next to mutation. Take the example code with error:
// trying to trick the type system into allowing this ref to be option<'a>
// this would allow for runtime type errors where we think foo.contents is something it isn't
let foo = ref(None)
foo.contents = Some(1)
// nope. This has type: string, Somewhere wanted: int
foo.contents = Some("haha I've fooled the type system")
But if I get trickier don’t use the ref right away, the compiler knows something is up:
// This expression's type contains type variables that can't be generalized
let foo = ref(None)
React internals use a bunch of mutation and ReScript is aware that might be the case. So when you have an unused generic in React, ReScript gets very nervous and lets you know that it’s uncomfortable with this message.