question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

usage of apply()/extend() with Typescript

See original GitHub issue

Hi, I am trying to make OrbitControls work with typescript but a key step is failing: apply({ OrbitControls }) as shown here https://github.com/drcmda/react-three-fiber/issues/27 and explained here https://github.com/drcmda/react-three-fiber#using-3rd-party-non-three-namespaced-objects-in-the-scene-graph

same behavior persists if i use extend instead

is it not supported? something to do with a missing declaration?

edit_1: the method itself gives no error but the impl of it <orbitControls /> says Property 'orbitControls' does not exist on type 'JSX.IntrinsicElements'.ts(2339)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

48reactions
edutercommented, Mar 26, 2020

If you want correct typing, you can do this:

import { extend, ReactThreeFiber } from 'react-three-fiber';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';


extend({ OrbitControls });

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'orbitControls': ReactThreeFiber.Object3DNode<OrbitControls, typeof OrbitControls>;
    }
  }
}
4reactions
Seanmclemcommented, Sep 13, 2021

@gsimone I don’t see that this is solved. I still get the same issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending object-like types with interfaces in TypeScript
Extending multiple interfaces refers to the concept of composition where the interface is designed to extend attributes it needs.
Read more >
usage of apply()/extend() with Typescript · Issue #130
Hi, I am trying to make OrbitControls work with typescript but a key step is failing: ... usage of apply()/extend() with Typescript #130....
Read more >
Handbook - Interfaces
Interfaces Extending Classes ... When an interface type extends a class type it inherits the members of the class but not their implementations....
Read more >
How to extend String Prototype and use it next, in Typescript?
There are two parts to extending a prototype in TypeScript. ... To use it, first import it: import '. ... toLowerCase().replace(/\b\w/g, (c: string)...
Read more >
Learn About Extension Methods In TypeScript
Extension -method gives you the power to add new methods to existing types. You don't have to create a new derived-type.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found