Three.js: Lint error in CubeCamera.d.ts

Created on 21 Oct 2020  路  3Comments  路  Source: mrdoob/three.js

Describe the bug

$ npm run test-lint

> [email protected] test-lint C:\Users\Takahiro\Documents\three.js
> eslint src --ext js --ext ts && tsc -p utils/build/tsconfig.lint.json

src/cameras/CubeCamera.d.ts(16,2): error TS2416: Property 'clear' in type 'CubeCamera' is not assignable to the same property in base type 'Object3D'.
  Type '(renderer: WebGLRenderer, color: boolean, depth: boolean, stencil: boolean) => void' is not assignable to type '() => this'.

To Reproduce

Run npm run test-lint in dev branch or see CI test results of any opened PR.

Code

In Object3D.d.ts

clear(): this;

In CubeCamera.d.ts

clear( renderer: WebGLRenderer, color: boolean, depth: boolean, stencil: boolean ): void;

I'm not familiar with TypeScript but I speculate a method can't be extended with different return type.

And Object.clear() behavior looks very different from CubeCamera.clear(). The former seems for removing children while the latter seems for clearing WebGL resources(?). I'd like to suggest renaming either one.

Expected behavior

Lint test should run without error.

Platform:

  • Device: Desktop
  • OS: Windows
  • Browser:
  • Three.js version: dev
TypeScript

Most helpful comment

I'm working on this today.

All 3 comments

I'm working on this today.

Just a friendly reminder 馃槆 : It's necessary to fix this issue until r122 will be released tomorrow. Otherwise the TS build is broken.

@mrdoob If you feel unsure about solving this, I suggest to revert the introduction of Object3D.clear() / Object3D.removeAll() and use the next dev cycle to find a solution.

Yeah. I'm preeeeeetty late on this one 馃槄

Was this page helpful?
0 / 5 - 0 ratings