pmndrs / pmndrs/three-stdlib

type errors on `addEventListener` for any class that extends from `EventDispatcher`

Open
#387 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
858
Forks
144
PR merge metrics
No merged PRs in 30d

Description

  • @types/three version: from 0.168.0
  • three-stdlib version: 2.34.0
Problem description:

@types/three introduced on v168 the breaking change that unknown events can no longer be dispatched in EventDispatcher (source).

Relevant code:

So now this will throw TS errors:

import { OrbitControls } from "three-stdlib";

const orbit = new OrbitControls();

orbit.addEventListener("start", ()=> console.log('started'));
// Argument of type 'string' is not assignable to parameter of type 'never'.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the listed OrbitControls addEventListener example with @types/three 0.168.0 and three-stdlib 2.34.0, then inspect the EventDispatcher typing used by OrbitControls. Done means the "start" listener type-checks without the string-to-never error while preserving event typing.

Written by the indexing model from the issue text.

Assessment

Tech stack
three.js, typescript
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.