(SOLVED) How to use types for addons

I just started learning/using Three.js

But was already I stumbled upon.
Since I’m the type of programmer that learns by using the code I wanted to have full Intellisense in VsCode.

So here is what I did to achieve this.
Setup your project as shown in the documentation.
Use the recommended way.

Then install the community types.
npm install --save-dev @types/three

After that you can use basic types for core functionality.
But if you also want to use types for addons: this is what I did.

  • Create a jsconfig.json in your project root folder.
  • Add the following content to it:
{
    "compilerOptions": {
        "paths": {
            "three/addons/controls/*": ["node_modules/@types/three/examples/jsm/controls/*"],
        },
        "baseUrl": "./"
    }
}
  • Save it

And your done. Now you also have Intellisense/Autocomplete for Addon functionality

2 Likes