fix(types): declare the hit-map fields the renderer puts on a texture source - #211
Merged
Conversation
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Devhas not compiled since theNitro → Octanerefactor:tscrejectsfourteen accesses to
hitMap,hitMapDirtyandhitMapTimeacrossAvatarImage.ts,ExtendedSprite.tsandTexturePool.ts.Those three fields are ours, not PixiJS's.
ExtendedSpritecaches a texture'salpha channel on the texture source so a pixel-perfect hit test does not
re-read the pixels on every mouse move;
GraphicAssetPalettefills the samefields when it bakes a recoloured texture, and
TexturePooldeletes them whenit recycles or destroys one.
Every one of those reads and writes used to sit behind a
@ts-ignore. Therefactor removed all seven, which is the right direction — a
@ts-ignoresilences 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 existingsource file.
Two details decide whether this works at all:
pixi.js. In aglobal script,
declare module 'pixi.js'declares an ambient module andshadows the real types instead of adding to them.
<T extends Record<string, any> = any>— or TypeScript rejects the merge.All three are optional, because
TexturePooldeletes them andExtendedSpritereadshitMapTimethrough?? 0.Verification
yarn compile(tsc),yarn compile:fast(tsgo) andyarn test— 72 files,395 tests — all pass.
Worth saying plainly: that run was on a tree three commits behind
Dev, whichstill carries the
@ts-ignorecomments, so it proves the declaration is validrather 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
Devbeing red blocks more than this repo.Octane's CI clones the rendererat
Devand type-checks against its source, so every client pull requestcurrently fails on these same fourteen errors regardless of what it changes.