Hi, I got a problem with this in typescript. If Moe component (or any of them) is a tsx file, on the "onClick={global.counter.reset}" the counter give me the following error: Property 'counter' does not exist on type '{}'.
What can I do to solve this? I've created an interface on the global file and in the component where I gave counter a "any" type but nothing helps... Thank you in advance. :)
Hi, I got a problem with this in typescript. If Moe component (or any of them) is a tsx file, on the "onClick={global.counter.reset}" the counter give me the following error: Property 'counter' does not exist on type '{}'.
What can I do to solve this? I've created an interface on the global file and in the component where I gave counter a "any" type but nothing helps... Thank you in advance. :)
I would need... something more tangible to help with specific code examples. Can you please provide a CodePen or StackBlitz??
Hi Pedro,
typescript is pretty explicit, there is no
counter
field on the global object,you have to declare the type so the compiler can do its job. Here is an example:
mariusschulz.com/blog/declaring-gl...