Skip to content

fix(types): declare the hit-map fields the renderer puts on a texture source - #211

Merged
SimoLeoLife merged 1 commit into
Devfrom
fix/texture-source-hit-map
Sep 6, 2026
Merged

fix(types): declare the hit-map fields the renderer puts on a texture source#211
SimoLeoLife merged 1 commit into
Devfrom
fix/texture-source-hit-map

Conversation

@SimoLeoLife

Copy link
Copy Markdown
Collaborator

Dev has not compiled since the Nitro → Octane refactor: tsc rejects
fourteen accesses to hitMap, hitMapDirty and hitMapTime across
AvatarImage.ts, ExtendedSprite.ts and TexturePool.ts.

Those three fields are ours, not PixiJS's. ExtendedSprite caches a texture's
alpha channel on the texture source so a pixel-perfect hit test does not
re-read the pixels on every mouse move; GraphicAssetPalette fills the same
fields when it bakes a recoloured texture, and TexturePool deletes them when
it recycles or destroys one.

Every one of those reads and writes used to sit behind a @ts-ignore. The
refactor removed all seven, which is the right direction — a @ts-ignore
silences the whole line rather than the one unknown property — but the
declarations that should take their place are not in the tree yet. This adds
them, so the suppressions stay gone without the compiler losing sight of the
fields.

What is in here

One new file, src/pixi-augmentations.d.ts. No change to any existing
source file.

hitMap?: Uint8Array | Uint8ClampedArray;
hitMapDirty?: boolean;
hitMapTime?: number;

Two details decide whether this works at all:

  • The file has to be a module, which is why it imports pixi.js. In a
    global script, declare module 'pixi.js' declares an ambient module and
    shadows the real types instead of adding to them.
  • The type parameter list has to match the class declaration
    <T extends Record<string, any> = any> — or TypeScript rejects the merge.

All three are optional, because TexturePool deletes them and
ExtendedSprite reads hitMapTime through ?? 0.

Verification

yarn compile (tsc), yarn compile:fast (tsgo) and yarn test — 72 files,
395 tests — all pass.

Worth saying plainly: that run was on a tree three commits behind Dev, which
still carries the @ts-ignore comments, so it proves the declaration is valid
rather than that it clears the fourteen errors. The CI run on this branch is
the check that matters for that.

Why it is worth landing quickly

Dev being red blocks more than this repo. Octane's CI clones the renderer
at Dev and type-checks against its source, so every client pull request
currently fails on these same fourteen errors regardless of what it changes.

… source

ExtendedSprite caches a texture's alpha channel on the texture source so a
pixel-perfect hit test does not re-read the pixels on every mouse move:
hitMap holds the bytes, hitMapDirty says they need regenerating, hitMapTime
throttles how often that happens. GraphicAssetPalette fills the same fields
when it bakes a recoloured texture, and TexturePool deletes them when it
recycles or destroys one.

None of the three belongs to PixiJS, so every read and write used to sit
behind a @ts-ignore. Those were removed, which is the right direction - a
@ts-ignore silences the whole line rather than the one unknown property - but
the declarations that should replace them are not in the tree, so tsc has
been rejecting all fourteen accesses since.

Declare the fields once instead. The file is a module, importing pixi.js for
exactly that reason: in a global script declare module 'pixi.js' would shadow
the real types rather than add to them. The type parameter list matches the
class declaration, or the merge would be rejected. All three are optional
because TexturePool deletes them and ExtendedSprite reads hitMapTime with ?? 0.

Verified locally: tsc compile, tsgo compile and 395 tests pass.
@SimoLeoLife
SimoLeoLife merged commit fb97775 into Dev Sep 6, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant