Three.js: TypeScript: stats.module.d.ts needs constructor arguments for Stats.Panel()

Created on 5 Jun 2020  路  3Comments  路  Source: mrdoob/three.js

Description of the problem

Stats.Panel() should allow for 3 optional arguments: name, fg and bg strings. However, the corresponding typescript declaration file doesn't allow for any arguments.

Three.js version
  • [x] r117
TypeScript

Most helpful comment

Would you mind opening a PR? None of the maintainers of this repository use TypeScript, so if those who are can test and contribute fixes that helps us with these reports.

All 3 comments

Would you mind opening a PR? None of the maintainers of this repository use TypeScript, so if those who are can test and contribute fixes that helps us with these reports.

I tested three.js in typescript in a few days ago, the terminal got an error.

import Stats from 'three/examples/jsm/libs/stats.module.js';

const stats = new Stats();
              ~~~~~~~~~~
document.body.appendChild( stats.dom );

terminal error information:

[tsl] ERROR in C:\threejs-project\src\index.ts(3,15)
    TS7009: 'new' expression, whose target lacks a construct signature, implicitly has an 'any' type.

@donmccurdy I'll work on it right now.

@linbingquan That error means you have to do it without the new keyword. Just const stats = Stats(); This is the only Three.js object I've come across that doesn't have a constructor like the others. It's just a function.

Was this page helpful?
0 / 5 - 0 ratings