When building my app containing three.js, using typescript, I get these new errors after upgrading to r111 from r106:
ERROR in /c/dss/Product/Horizon/WebProjects/horizon-project/horizon-three-ngl/node_modules/three/src/core/BufferAttribute.d.ts
21:6 An accessor cannot be declared in an ambient context.
19 | count: number;
20 |
> 21 | set needsUpdate( value: boolean );
| ^
22 |
23 | isBufferAttribute: true;
24 |
ERROR in /c/dss/Product/Horizon/WebProjects/horizon-project/horizon-three-ngl/node_modules/three/src/core/InterleavedBufferAttribute.d.ts
19:6 An accessor cannot be declared in an ambient context.
17 | normalized: boolean;
18 |
> 19 | get count(): number;
| ^
20 | get array(): ArrayLike<number>;
21 |
22 | isInterleavedBufferAttribute: true;
ERROR in /c/dss/Product/Horizon/WebProjects/horizon-project/horizon-three-ngl/node_modules/three/src/core/InterleavedBufferAttribute.d.ts
20:6 An accessor cannot be declared in an ambient context.
18 |
19 | get count(): number;
> 20 | get array(): ArrayLike<number>;
| ^
21 |
22 | isInterleavedBufferAttribute: true;
23 |
ERROR in /c/dss/Product/Horizon/WebProjects/horizon-project/horizon-three-ngl/node_modules/three/src/renderers/webgl/WebGLAttributes.d.ts
6:43 Cannot find name 'WebGL2RenderingContext'.
4 | export class WebGLAttributes {
5 |
> 6 | constructor( gl: WebGLRenderingContext | WebGL2RenderingContext );
| ^
7 |
8 | get( attribute: BufferAttribute | InterleavedBufferAttribute ): {
9 | buffer: WebGLBuffer,
...
Version: typescript 3.4.5
I didn't see anything in the migration guide about requiring a newer typescript, but I believe at least the first few are due to how typescript 3.7 outputs accessors
in .d.ts files, as in https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html:
To detect the issue around accessors, TypeScript 3.7 will now emit get/set accessors in .d.ts files so that in TypeScript can check for overridden accessors.
But these are not parsed properly by earlier Typescript versions like my 3.4.5.
Upgrading my typescript to 3.7.3 fixes the problem for me.
Upgrading my typescript to 3.7.3 fixes the problem for me.
three.js already has the following TS package config:
https://github.com/mrdoob/three.js/blob/b07ce26cf1d4b9056f4fc73b049e8bccf8e9472b/package.json#L87
Shouldn't you automatically get 3.7.3 when installing three?
Makes sense. I have a complicated monorepo so I guess that's why I the typescript requirement didn't bubble up properly.
Makes sense. I have a complicated monorepo so I guess that's why I the typescript requirement didn't bubble up properly.
+1
I have a monorepo which has angular, i had TS ~3.5.3 defined and three ^0.109.0 which are now:
"three": "^0.111.0",
and
"typescript": "^3.7.2"
and
"@angular-devkit/build-angular": "~0.803.12",
Working ok!
Most helpful comment
Makes sense. I have a complicated monorepo so I guess that's why I the typescript requirement didn't bubble up properly.