Typescript definition updated and wrong?

There is a snippet in my question explaining why this won’t compile in typescript. I believe the type definitions are outdated. For the version I’m using ^8.6. For the state variable it’s defined above, sorry for not being clear. I now edited my question so it’s clearer…