triplex icon indicating copy to clipboard operation
triplex copied to clipboard

When userland tsconfig is missing r3f types it can cause unexpected errors

Open verekia opened this issue 2 years ago • 7 comments

The following component:

const Crystal = ({ x, y }) => (
  <group position={[x, y, 1.5]} scale={4}>
    <mesh>
      <boxGeometry />
      <meshStandardMaterial />
    </mesh>
  </group>
)

export default Crystal

causes the error Error reading "[...]src/components/models/Crystal.tsx/object/3/5/types" - [Error: Could not find the node's symbol.

Triplex 0.54.1

verekia avatar Jul 06 '23 15:07 verekia

So box geometry can't be found? Is this when clicking it in the editor or when adding an element?

itsdouges avatar Jul 09 '23 09:07 itsdouges

Heya I'm able to open this with no error. Can you confirm on the latest Triplex version @verekia?

image

itsdouges avatar Aug 23 '23 09:08 itsdouges

It's still happening for me.

Screenshot 2023-08-25 at 14 39 42

I clicked on the component in the left panel, and nothing showed up. Then, the error shows if I click group on the left.

"@triplex/run": "0.55.3",
"@react-three/drei": "9.74.15",
"@react-three/fiber": "8.13.3",
"react": "18.2.0",
"react-dom": "18.2.0",
"three": "0.153.0",

app/.triplex/config.json:

{
  "components": ["../src/components/**/*.tsx"],
  "files": ["../src/**/*.tsx"]
}

Component is located at app/src/components/Crystal.tsx.

Edit: the same error still happens with updated dependencies:

"@triplex/run": "0.55.3",
"@react-three/drei": "9.80.6",
"@react-three/fiber": "8.13.7",
"react": "18.2.0",
"react-dom": "18.2.0",
"three": "0.155.0",

verekia avatar Aug 25 '23 07:08 verekia

Can you add a short video?

itsdouges avatar Aug 25 '23 08:08 itsdouges

Okay so:

  1. The mesh doesn't show up because position is being set to [undefined, undefined, 1.5] which is an invalid position. If you set x and y to default to 0 it starts working
  2. As for the error, I can't replicate it. I think it might be fixed in the latest version. Can you check please?

itsdouges avatar Aug 30 '23 12:08 itsdouges

Add this to your tsconfig:

"compilerOptions": {
  "types": ["@react-three/fiber"]
}

itsdouges avatar Sep 02 '23 12:09 itsdouges

That did the trick! It doesn't even throw any more on undefined values.

verekia avatar Sep 03 '23 08:09 verekia