Let's take a look at the type definitions and find out:
interface Component<P = {}, S = {}> extends ComponentLifecycle<P, S> { }
class Component<P, S> {
/* ... */
}
Both P (the type parameter for the props) and S (the type parameter for the state) default to {}, meaning that both the props and state have the type of an empty object.
So in the cases you've specified:
- You don't provide a type for
S, so it defaults to {}.
- You provide
any as the type for S - this is not the same as {}, as it allows you to set the state to anything at all (a number, a string, etc.). I have no idea if that'll actually work in practice, given the way the setState API works, but you can try it if you want.
- You provide
{} as the type for S, which is the same as the default.
So in short, 1 and 3 are the same, but 2 is not.