Skip to content

TS: Vector3 interface not descriptive enough to support this valid usage #19303

@Antony74

Description

@Antony74
Description of the problem

The following code works, but TypeScript does not compile with the present Vector3.d.ts

  // vector between center of head and center of ear
  const earVector = new THREE.Vector3(1.44, 0.6, -0.3);

  const leftEar = new THREE.SphereGeometry(1, 32, 32).applyMatrix4(new THREE.Matrix4().makeScale(0.4, 0.4, 0.25));
  const rightEar = leftEar.clone();

  leftEar.translate(...earVector.toArray());
  earVector.x = -earVector.x;
  rightEar.translate(...earVector.toArray());

BUG (compile error):
Expected 3 arguments, but got 0 or more. ts(2556)

EXPECTED:
Given that the code behaves as expected, I would expect it to compile.
(I would also expect the aesthetics of this use of the spread operator to divide opinion)

Three.js version
  • Dev
  • r116
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions