brianzinn / react-babylonjs

React for Babylon 3D engine
https://brianzinn.github.io/react-babylonjs/
812 stars 102 forks source link

"Type instantiation is excessively deep and possibly infinite" Typescript error when used with Chakra-UI #248

Closed mikecann closed 1 year ago

mikecann commented 1 year ago

As the title suggests you get typescript errors when you try to combine react-babylonjs with Chakra-UI.

I suspect that this is a common issue with React Fibre when combined with complex UI frameworks. See these other issues from similar libs:

https://github.com/pmndrs/react-three-fiber/discussions/1752 https://github.com/pmndrs/react-spring/issues/1515 https://github.com/microsoft/TypeScript/issues/34933 https://stackoverflow.com/questions/69625898/typescript-box-produces-a-union-type-that-is-too-complex-to-represent

I honestly dont know what you can do about it. Its really annoying as I was looking forward to using ract-babylon but there is no way we can refactor out chakra at this stage.

If this is not fixable feel free to close.

brianzinn commented 1 year ago

Can you share your code that causes this error? I have, for example, a Box export, but I am happy to remove it as it's unneeded and maybe even confusing, but perhaps you have something else - looks like may be a globals conflict...

mikecann commented 1 year ago

Hmm I just had a shot at trying to make it fail but I failed:

https://codesandbox.io/s/eloquent-tesla-rnvk8g?file=/src/App.tsx

It seems to work fine.. I guess the issue is my end then, some combination of my dependencies + builder... sigh

brianzinn commented 1 year ago

Sometimes codesandbox is more forgiving than VS Code. Can still be an issue here.