I am using ThreeJS ES6 native modules directly in the browser. It's a really cool feature where you can just import
ThreeJS from your javascript files without any module bundler.
The following works in javascript:
import * as THREE from './lib/three.module.js'
import { OrbitControls } from './lib/OrbitControls.js'
Now I want to do this in Typescript, I installed the typescript definitions using
npm install --save @types/three
But VS Code still can't find the type declaration files:
⚠️ Could not find a declaration file for module '../lib/three.module.js'
⚠️ Could not find a declaration file for module '../lib/OrbitControls.js'.
As suggested in the comments I changed the imports to
import * as THREE from 'three'
import { OrbitControls } from three/examples/jsm/controls/OrbitControls'
Now the declarations are found, but typescript can't find the modules!
⚠️ An accessor cannot be declared in an ambient context and Failed to resolve module specifier "three".
⚠️ Relative references must start with either "/", "./", or "../".
How can I use ES6 native modules from ThreeJs in my Typescript project without a module bundler?