Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position and Points property not compatible with readonly types | Typescript #2374

Closed
Brandontam29 opened this issue Jul 19, 2022 · 1 comment · Fixed by #2428
Closed

Position and Points property not compatible with readonly types | Typescript #2374

Brandontam29 opened this issue Jul 19, 2022 · 1 comment · Fixed by #2428
Labels
bug Something isn't working Typescript issues to do with TS

Comments

@Brandontam29
Copy link

Explanation
I am getting these two typescript errors concerning valtio readonly types with position property of elements in react-three-fiber. From my understanding, react-three-fiber components should accept readonly types since the library doesn't mutate the values. I can be wrong, so please let me know how this was intended to work.

First example

const Component= () => {
  const snapshot= useSnapshot(snapshot);
  const { point0 } = snapshot;
  
  return <Line position={point0} />
}

The position ={point0} will give off the following error
The type 'readonly [number, number, number]' is 'readonly' and cannot be assigned to the mutable type '[x: number, y: number, z: number]'

Second example

const Component= () => {
  const snapshot= useSnapshot(snapshot);
  const { point0, point1, point2 } = snapshot;
  
  return <Line points={[point0, point1, point2]} />
}

The points={[point0, point1, point2]} will give off the following error
Type 'readonly [number, number, number]' is not assignable to type 'Vector3 | [number, number, number]'.ts(2322)

@CodyJasonBennett
Copy link
Member

Fixed in v8.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Typescript issues to do with TS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants