Angular Сбой сборки после добавления трех. js - PullRequest
0 голосов
/ 26 января 2020

Я создал приложение fre sh Angular, добавил three и @types/three и создал базовый c компонент. Но когда я запускаю ng build --prod, я получаю следующие ошибки:

ERROR in node_modules/three/src/core/BufferAttribute.d.ts:21:6 - error TS1086: An accessor cannot be declared in an ambient context.

21  set needsUpdate( value: boolean );
        ~~~~~~~~~~~
node_modules/three/src/renderers/webgl/WebGLUtils.d.ts:3:43 - error TS2304: Cannot find name 'WebGL2RenderingContext'.

3  constructor( gl: WebGLRenderingContext | WebGL2RenderingContext, extensions: any, capabilities: any );
                                            ~~~~~~~~~~~~~~~~~~~~~~
node_modules/three/src/core/InterleavedBufferAttribute.d.ts:20:6 - error TS1086: An accessor cannot be declared in an ambient context.

20  get count(): number;
        ~~~~~
node_modules/three/src/core/InterleavedBufferAttribute.d.ts:21:6 - error TS1086: An accessor cannot be declared in an ambient context.

21  get array(): ArrayLike<number>;
        ~~~~~
node_modules/three/src/renderers/webgl/WebGLAttributes.d.ts:6:43 - error TS2304: Cannot find name 'WebGL2RenderingContext'.

6  constructor( gl: WebGLRenderingContext | WebGL2RenderingContext );

Добавление three в массив типов Typescript не помогло:

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": ["three"]
  },
  "files": ["src/main.ts", "src/polyfills.ts"],
  "include": ["src/**/*.ts"],
  "exclude": ["src/test.ts", "src/**/*.spec.ts"]
}

1 Ответ

1 голос
/ 26 января 2020

three.js зависит от TypeScript 3.7. Начиная с @angular/cli@9.0.0-rc.10 и @angular/core@9.0.0-rc.9, вы также сможете использовать TypeScript 3.7 с Angular. Подробнее об этом в репозитории Angular:

https://github.com/angular/angular-cli/issues/16071#issuecomment -577109414

three.js R112

...