Getting error after imported in Angular 7

When I try to add Three JS to my Angular 7 project. I’ve installed npm install three --save and npm install @type/webgl2 into my project, then when I start to import it shows a bunch error in my terminal
ERROR in node_modules/three/src/core/BufferAttribute.d.ts(21,6): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/three/src/core/InterleavedBufferAttribute.d.ts(19,6): error TS1086: An accessor cannot be declared in an ambient context.
node_modules/three/src/core/InterleavedBufferAttribute.d.ts(20,6): error TS1086: An accessor cannot be declared in an ambient context.

Can you guys know why I’m getting this error or I need other dependencies for getting it to work?
This is what I have imported to my controller
import * as THREE from ‘three’;

1 Like

What version of TS are you using in your project? There seems to be an issue with newer TS versions (https://github.com/googleapis/node-gtoken/issues/244).

/cc

I got the same error. If i update typescript to 3.6.4, the error is gone, but I cannot compile anymore:

The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.6.4 was found instead.

Installing OffscreenCanvas and Webgl2 did not help. Need a solution for this! I cannot build for production

Simply downgrade three.js version to ^0.110.0