pmndrs / pmndrs/react-three-examples

Mechanical sweep: prefer plain 'as X' over 'as unknown as X' where the compiler allows it

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

Nobody has claimed this yet.

good first issue
Dominant language
TypeScript
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

What

A sweep of the corpus's 97 as unknown as sites found several documented-legitimate casts
(real @types/three gaps: PassNode.options — B11, BloomNode.highPassFn — B24,
Points.count — B34) that typecheck fine with the unknown intermediate hop dropped — a
plain as { options: … } / as ReturnType<typeof …> compiles clean, because the target
type still overlaps the source closely enough for TS's single-step assertion rule.

The double-hop form isn't wrong (it's the maximally-permissive form and never fails), but
it's stronger than the gap requires and reads as "TS is fighting me here" when a lighter
cast would do. One family (the backgroundNode/fogNode/environmentNode sites) was
already fully removed in an earlier sweep because @types/three closed that gap entirely.
This issue is about the remaining ~10 files' worth of double-hop casts that are still
necessary but could be single-hop.

Why it matters

Corpus-wide in reach but cosmetic — no correctness or behavior change, purely how tightly
each cast is scoped. Worth doing as a deliberate, verifiable pass (test each site with
as X, keep as unknown as X only where the compiler still demands it) rather than
mixed into an unrelated task, since verifying ~10 sites individually against tsc is
exactly mechanical-but-not-zero-risk enough to want its own PR and diff.

Recommendation already on file

docs/REVIEW-QUEUE.md #16: worth doing in the same pass as whatever normalizes the B11
comment wording, not as a rushed follow-up to a task whose ask was "remove the unnecessary
ones" rather than "minimize the necessary ones."

Pointer

docs/REVIEW-QUEUE.md §16 ("as unknown as X vs plain as X — should the corpus prefer
the minimal cast?").

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

Read docs/REVIEW-QUEUE.md §16, then search the corpus for the remaining as unknown as sites, especially the documented B11, B24, and B34 cases. Try the corresponding single-step assertions and verify each with tsc; done means eligible casts use the plain form while casts still required by the compiler remain unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.