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

Any plans to support ambient XRFrame definition? #2501

Closed
kentdotn opened this issue Sep 17, 2022 · 9 comments · Fixed by #2377 or #3052
Closed

Any plans to support ambient XRFrame definition? #2501

kentdotn opened this issue Sep 17, 2022 · 9 comments · Fixed by #2377 or #3052
Labels
bug Something isn't working dependencies An upstream issue to do with dependencies Typescript issues to do with TS

Comments

@kentdotn
Copy link

Hi,

I recently bumped into a problem that transpiling ts code using the combination of the latest react-three/fiber and @types/three results in a following compilation error.

Namespace '"@types/three/index"' has no exported member 'XRFrame'.

Setting skipLibCheck: true avoids the problem but I don't want to skip it if we could.
So, are there any plans to support ambient XRFrame as well as the latest three?

I understand the situation that the breaking change in r141 was intended and therefore @types/three has no motivation to fix it, so I wish react-three-fiber would make some fixes in its usage.

@CodyJasonBennett
Copy link
Member

CodyJasonBennett commented Sep 17, 2022

We have a v9 branch that addresses this (#2331), yes. We're also catching up the rest of the ecosystem (three-stdlib, Drei, react-xr) since it is such a breaking change.

@kentdotn
Copy link
Author

Great news!!
I'm longing for v9 so much!

@CodyJasonBennett
Copy link
Member

CodyJasonBennett commented Sep 17, 2022

I'm not sure of a way for us to fix this outside of major semver, but another workaround could be:

type XRFrameImpl = XRFrame
type XRFrameRequestCallbackImpl = XRFrameRequestCallback

declare module 'three' {
  interface XRFrame extends XRFrameImpl {}
  type XRFrameRequestCallback = XRFrameRequestCallbackImpl
}

@CodyJasonBennett CodyJasonBennett added bug Something isn't working dependencies An upstream issue to do with dependencies Typescript issues to do with TS labels Sep 17, 2022
@kentdotn
Copy link
Author

Yeah, that was my concern since it narrows supported three versions down.

The alternative approach you wrote might help, but when I tried in the same approach, I got so many errors and I gave up. Some additional tricks may be needed, I believe.

@kentdotn
Copy link
Author

kentdotn commented Sep 17, 2022

Correction: the approach works.
When I put it in an ambient declaration file, that hides any other symbols from @types/three and emits errors.
When I put it in a typescript source file instead, it just adds XRFrame in three module.

Only problem that remains is this approach still does not compatible for older versions three.js (<141) since there's no webxr's ambient declarations and the top-level XRFrame definition. I tried to import @types/webxr using triple-slash reference and that fixes the issue, but then, I got duplicate identifier 'XRFrame' incorrectly extends interface 'XRFrame'. since that definition is already there.

Though, for my problem, this will suffice. Thank you!

@Zemnmez
Copy link

Zemnmez commented Apr 18, 2023

I'm not seeing this problem fixed right now, though #2377 has been merged, and the GitHub UI says it should close this issue.

@kentdotn
Copy link
Author

IIUC, v9 has not been released yet and the fix was merged into v9 branch only, v8 users could still affect this problem.
If so, isn't it good to hold this issue open until v9 officially released?

@Zemnmez
Copy link

Zemnmez commented Apr 18, 2023

That makes sense to me. Apologies, I did not know which versions were affected.

@CodyJasonBennett
Copy link
Member

Published v8.15.1 with a workaround.

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