Repository: League-of-Foundry-Developers/foundry-vtt-types
Pull request #3056 (2025-02-02 11:04:47)

Types and tests for `pixi/core/shapes`
also `ClockwiseSweepPolygon`
also removed three global types (two by simplification, and `PointSourcePolygonConfig` is now `PointSourcePolygon.Config`)


Patch:
diff --git a/src/configuration/globals.d.mts b/src/configuration/globals.d.mts
index 1bafad506..382b6f14f 100644
--- a/src/configuration/globals.d.mts
+++ b/src/configuration/globals.d.mts
@@ -96,6 +96,7 @@ export import ClientPackage = globalThis.ClientPackage;
 export import ClientPackageMixin = globalThis.ClientPackageMixin;
 export import ClientSettings = globalThis.ClientSettings;
 export import ClipperLib = globalThis.ClipperLib;
+export import ClockwiseSweepPolygon = globalThis.ClockwiseSweepPolygon;
 export import ColorAdjustmentsSamplerShader = globalThis.ColorAdjustmentsSamplerShader;
 export import ColorationVisionShader = globalThis.ColorationVisionShader;
 export import Combat = globalThis.Combat;
diff --git a/src/foundry/client-esm/canvas/edges/collision.d.mts b/src/foundry/client-esm/canvas/edges/collision.d.mts
index 0203ed597..90133d264 100644
--- a/src/foundry/client-esm/canvas/edges/collision.d.mts
+++ b/src/foundry/client-esm/canvas/edges/collision.d.mts
@@ -1,3 +1,4 @@
+import type Edge from "./edge.d.mts";
 /**
  * A specialized object that contains the result of a collision in the context of the ClockwiseSweepPolygon.
  * This class is not designed or intended for use outside of that context.
@@ -7,8 +8,8 @@ declare class CollisionResult {
   constructor(values?: {
     target?: foundry.canvas.edges.PolygonVertex;
     collisions?: foundry.canvas.edges.PolygonVertex[];
-    cwEdges?: EdgeSet;
-    ccwEdges?: EdgeSet;
+    cwEdges?: Set<Edge>;
+    ccwEdges?: Set<Edge>;
     isBehind?: boolean;
     isLimited?: boolean;
     wasLimited?: boolean;
@@ -30,13 +31,13 @@ declare class CollisionResult {
    * The set of edges connected to the target vertex that continue clockwise
    * @defaultValue `new Set()`
    */
-  cwEdges: EdgeSet;
+  cwEdges: Set<Edge>;
 
   /**
    * The set of edges connected to the target vertex that continue counter-clockwise
    * @defaultValue `new Set()`
    */
-  ccwEdges: EdgeSet;
+  ccwEdges: Set<Edge>;
 
   /**
    * Is the target vertex for this result behind some closer active edge?
diff --git a/src/foundry/client-esm/canvas/edges/vertex.d.mts b/src/foundry/client-esm/canvas/edges/vertex.d.mts
index 641b259e9..774ec1672 100644
--- a/src/foundry/client-esm/canvas/edges/vertex.d.mts
+++ b/src/foundry/client-esm/canvas/edges/vertex.d.mts
@@ -25,19 +25,19 @@ declare class PolygonVertex {
    * This set is initially empty and populated later after vertices are de-duplicated.
    * @defaultValue `new Set()`
    */
-  edges: EdgeSet;
+  edges: Set<Edge>;
 
   /**
    * The subset of edges which continue clockwise from this vertex.
    * @defaultValue `new Set()`
    */
-  cwEdges: EdgeSet;
+  cwEdges: Set<Edge>;
 
   /**
    * The subset of edges which continue counter-clockwise from this vertex.
    * @defaultValue `new Set()`
    */
-  ccwEdges: EdgeSet;
+  ccwEdges: Set<Edge>;
 
   /**
    * The set of vertices collinear to this vertex
diff --git a/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts b/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts
index 591171bbc..f46327367 100644
--- a/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts
+++ b/src/foundry/client-esm/canvas/sources/point-darkness-source.d.mts
@@ -62,7 +62,7 @@ declare class PointDarknessSource<
 
   override _configure(changes: IntentionalPartial<SourceData>): void;
 
-  override _getPolygonConfiguration(): PointSourcePolygonConfig;
+  override _getPolygonConfiguration(): PointSourcePolygon.Config;
 
   override _drawMesh(layerId: string): PIXI.Mesh | null;
 
diff --git a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts
index 85e3e02aa..ada8f3d19 100644
--- a/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts
+++ b/src/foundry/client-esm/canvas/sources/point-effect-source.d.mts
@@ -37,8 +37,7 @@ declare class PointEffectSource {
   /**
    * Configure the parameters of the polygon that is generated for this source.
    */
-  //TODO: Make sure this is accurate as part of work on "pixi leftovers"
-  protected _getPolygonConfiguration(): PointSourcePolygonConfig;
+  protected _getPolygonConfiguration(): PointSourcePolygon.Config;
 
   _createShapes(): void;
 
diff --git a/src/foundry/client-esm/canvas/sources/point-light-source.d.mts b/src/foundry/client-esm/canvas/sources/point-light-source.d.mts
index 87036fd52..4d56aca10 100644
--- a/src/foundry/client-esm/canvas/sources/point-light-source.d.mts
+++ b/src/foundry/client-esm/canvas/sources/point-light-source.d.mts
@@ -24,7 +24,7 @@ declare class PointLightSource<
 
   override _configure(changes: IntentionalPartial<SourceData>): void;
 
-  override _getPolygonConfiguration(): PointSourcePolygonConfig;
+  override _getPolygonConfiguration(): PointSourcePolygon.Config;
 
   /**
    * Test whether this LightSource provides visibility to see a certain target object.
diff --git a/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts b/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts
index 389c19057..b62420ddb 100644
--- a/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts
+++ b/src/foundry/client-esm/canvas/sources/point-sound-source.d.mts
@@ -20,7 +20,7 @@ declare class PointSoundSource<
 
   override get effectsCollection(): Collection<this>;
 
-  override _getPolygonConfiguration(): PointSourcePolygonConfig;
+  override _getPolygonConfiguration(): PointSourcePolygon.Config;
 
   /**
    * Get the effective volume at which an AmbientSound source should be played for a certain listener.
diff --git a/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts b/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts
index cf04b71ef..db278c2a3 100644
--- a/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts
+++ b/src/foundry/client-esm/canvas/sources/point-vision-source.d.mts
@@ -127,7 +127,7 @@ declare class PointVisionSource<
 
   override _configureLayer(layer: RenderedEffectSource.SourceLayer, layerId: string): void;
 
-  override _getPolygonConfiguration(): PointSourcePolygonConfig;
+  override _getPolygonConfiguration(): PointSourcePolygon.Config;
 
   /**
    * Creates the polygon that represents light perception.
diff --git a/src/foundry/client/pixi/board.d.mts b/src/foundry/client/pixi/board.d.mts
index d86f899bc..3e50b6213 100644
--- a/src/foundry/client/pixi/board.d.mts
+++ b/src/foundry/client/pixi/board.d.mts
@@ -781,6 +781,8 @@ declare global {
      */
     type PointArray = [x: number, y: number];
 
+    type PairOfPointsArray = [x0: number, y0: number, x1: number, y1: number];
+
     /**
      * A standard rectangle interface.
      * @remarks Copied from `resources/app/common/types.mjs`
diff --git a/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts b/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts
index 702e3ce50..4899d9528 100644
--- a/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts
+++ b/src/foundry/client/pixi/core/shapes/limited-angle-polygon.d.mts
@@ -1,4 +1,4 @@
-export {};
+import type { InexactPartial } from "../../../../../utils/index.d.mts";
 
 declare global {
   /**
@@ -6,12 +6,12 @@ declare global {
    * The shape is defined by a point origin, radius, angle, and rotation.
    * The shape is further customized by a configurable density which informs the approximation.
    * An optional secondary externalRadius can be provided which adds supplementary visibility outside the primary angle.
+   * @param origin - The origin point for this polygon
+   * @param config - Configuration for the polygon.
+   * @remarks Despite `config` being an `={}` parameter, the `radius` key must be passed to avoid `NaN`s
    */
   class LimitedAnglePolygon extends PIXI.Polygon {
-    constructor(
-      origin: Canvas.Point,
-      { radius, angle, rotation, density, externalRadius }: LimitedAnglePolygon.ConstructorOptions,
-    );
+    constructor(origin: Canvas.Point, config: LimitedAnglePolygon.ConstructorOptions);
 
     /**
      * The origin point of the Polygon
@@ -59,6 +59,12 @@ declare global {
      */
     aMax: number;
 
+    /**
+     * The bounding box of the circle defined by the externalRadius, if any
+     * @privateRemarks Set in `##generatePoints`, which is called at the end of the constructor
+     */
+    externalBounds: PIXI.Rectangle;
+
     /**
      * Restrict the edges which should be included in a PointSourcePolygon based on this specialized shape.
      * We use two tests to jointly keep or reject edges.
@@ -67,9 +73,9 @@ declare global {
      * @param a - The first edge vertex
      * @param b - The second edge vertex
      * @returns Should the edge be included in the PointSourcePolygon computation?
-     * @internal
+     * @remarks Foundry marked `@internal`
      */
-    protected _includeEdge(a: Canvas.Point, b: Canvas.Point): boolean;
+    _includeEdge(a: Canvas.Point, b: Canvas.Point): boolean;
 
     /**
      * Test whether a vertex lies between two boundary rays.
@@ -85,35 +91,49 @@ declare global {
   }
 
   namespace LimitedAnglePolygon {
-    interface ConstructorOptions {
-      /**
-       * The radius of the emitted cone.
-       */
-      radius: number;
+    interface Any extends AnyLimitedAnglePolygon {}
+    type AnyConstructor = typeof AnyLimitedAnglePolygon;
 
+    /** @internal */
+    type _ConstructorOptions = InexactPartial<{
       /**
        * The angle of the Polygon in degrees.
        * @defaultValue `360`
+       * @remarks Can't be `null` as it only has a parameter default
        */
-      angle?: number;
+      angle: number;
 
       /**
        * The direction of rotation at the center of the emitted angle in degrees.
        * @defaultValue `0`
+       * @remarks Can't be `null` as it only has a parameter default
        */
-      rotation?: number;
+      rotation: number;
 
       /**
        * The density of rays which approximate the cone, defined as rays per PI.
        * @defaultValue `PIXI.Circle.approximateVertexDensity(this.radius)`
        */
-      density?: number;
+      density: number | null;
 
       /**
        * An optional "external radius" which is included in the polygon for the supplementary area outside the cone.
        * @defaultValue `0`
+       * @remarks Only used if truthy
        */
-      externalRadius?: number;
+      externalRadius: number | null;
+    }>;
+
+    interface ConstructorOptions extends _ConstructorOptions {
+      /**
+       * The radius of the emitted cone.
+       * @privateRemarks This is given no default, but is directly used in multiplication and division, resulting in `NaN` if allowed to be `undefined`
+       */
+      radius: number;
     }
   }
 }
+
+declare abstract class AnyLimitedAnglePolygon extends LimitedAnglePolygon {
+  constructor(arg0: never, ...args: never[]);
+}
diff --git a/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts b/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts
index fb4f14d94..d153a77b8 100644
--- a/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts
+++ b/src/foundry/client/pixi/core/shapes/polygon-mesher.d.mts
@@ -1,4 +1,4 @@
-import type { InexactPartial } from "fvtt-types/utils";
+import type { IntentionalPartial } from "fvtt-types/utils";
 
 declare global {
   /**
@@ -10,14 +10,13 @@ declare global {
      * @param poly    - Closed polygon to be processed and converted to a mesh
      *                  (array of points or PIXI Polygon)
      * @param options - Various options : normalizing, offsetting, add depth, ...
+     * @remarks `options` is `IntentionalPartial`'d because the constructor immediately does
+     * `this.options = {...this.constructor._defaultOptions, ...options}`, so explicit `undefined` would break things
      */
-    constructor(poly: number[] | PIXI.Polygon, options?: InexactPartial<PolygonMesherOptions>);
-
-    /** Contains options to apply during the meshing process */
-    options: PolygonMesherOptions;
+    constructor(poly: PIXI.Polygon.OrPointsFlat, options?: IntentionalPartial<PolygonMesher.Options>);
 
     /** Default options values */
-    static _defaultOptions: PolygonMesherOptions;
+    static _defaultOptions: PolygonMesher.Options;
 
     /**
      * Polygon mesh vertices
@@ -29,14 +28,20 @@ declare global {
      */
     indices: number[];
 
+    /** Contains options to apply during the meshing process */
+    options: PolygonMesher.Options;
+
     /**
      * Convert a flat points array into a 2 dimensional ClipperLib path
      * @param poly      - PIXI.Polygon or points flat array.
      * @param dimension - Dimension.
      *                    (default 2)
      * @returns The clipper lib path.
+     * @throws If `dimension < 2`
+     * @privateRemarks Foundry types this return as `number[] | undefined`, but it cannot return either of those;
+     * Either it will throw or return a (possibly empty) `ClipperLib.Path` (an array-like of `ClipperLib.IntPoint`s)
      */
-    static getClipperPathFromPoints(poly: number[] | PIXI.Polygon, dimension?: number): number[] | undefined;
+    static getClipperPathFromPoints(poly: PIXI.Polygon.OrPointsFlat, dimension?: number): ClipperLib.Path;
 
     /**
      * Execute the triangulation to create indices
@@ -46,65 +51,88 @@ declare global {
     triangulate(geometry: PIXI.Geometry): PIXI.Geometry;
   }
 
-  interface PolygonMesherOptions {
-    /**
-     * The position value in pixels
-     * @defaultValue `0`
-     */
-    offset: number;
-
-    /**
-     * Should the vertices be normalized?
-     * @defaultValue `false`
-     */
-    normalize: boolean;
-
-    /**
-     * The x origin
-     * @defaultValue `0`
-     */
-    x: number;
-
-    /**
-     * The y origin
-     * @defaultValue `0`
-     */
-    y: number;
-
-    /**
-     * The radius
-     * @defaultValue `0`
-     */
-    radius: number;
-
-    /**
-     * The depth value on the outer polygon
-     * @defaultValue `0`
-     */
-    depthOuter: number;
-
-    /**
-     * The depth value on the inner polygon
-     * @defaultValue `1`
-     */
-    depthInner: number;
+  namespace PolygonMesher {
+    interface Any extends AnyPolygonMesher {}
+    type AnyConstructor = typeof AnyPolygonMesher;
 
     /**
-     * Constant multiplier to avoid floating point imprecision with ClipperLib
-     * @defaultValue `10e8`
+     *  @remarks These properties all have non-nullish values in `_defaultOptions`, and explicit `undefined` breaks
+     * things that aren't `boolean` due to math and object spread syntax in the constructor. `null` has been allowed
+     * where its casting to `0` or `false` doesn't break things.
      */
-    scale: number;
-
-    /**
-     * Distance of the miter limit, when sharp angles are cut during offsetting.
-     * @defaultValue `7`
-     */
-    miterLimit: number;
-
-    /**
-     * Should the vertex data be interleaved into one VBO?
-     * @defaultValue `false`
-     */
-    interleaved: boolean;
+    interface Options {
+      /**
+       * The position value in pixels
+       * @defaultValue `0`
+       * @remarks Can't be `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      offset: number | null;
+
+      /**
+       * Should the vertices be normalized?
+       * @defaultValue `false`
+       */
+      normalize: boolean | undefined | null;
+
+      /**
+       * The x origin
+       * @defaultValue `0`
+       * @remarks Can't be `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      x: number | null;
+
+      /**
+       * The y origin
+       * @defaultValue `0`
+       * @remarks Can't be `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      y: number | null;
+
+      /**
+       * The radius
+       * @defaultValue `0`
+       * @remarks Can't be `null` because of an `=== 0` check, nor `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      radius: number;
+
+      /**
+       * The depth value on the outer polygon
+       * @defaultValue `0`
+       * @remarks Can't be `null` as it can be pushed directly into a `number[]`, nor `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      depthOuter: number;
+
+      /**
+       * The depth value on the inner polygon
+       * @defaultValue `1`
+       * @remarks Can't be `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      depthInner: number | null;
+
+      /**
+       * Constant multiplier to avoid floating point imprecision with ClipperLib
+       * @defaultValue `10e8`
+       * @remarks Not allowing `null` because a zero value here defeats the purpose, and `undefined` because the default is provided by spread operator and the value is used directly in math
+       */
+      scale: number;
+
+      /**
+       * Distance of the miter limit, when sharp angles are cut during offsetting.
+       * @defaultValue `7`
+       * @remarks Allowed to be `undefined` but not `null` because it is passed to
+       * `new ClipperLib.ClipperOffset()`, which provides its own default if `=== undefined`
+       */
+      miterLimit: number | undefined;
+
+      /**
+       * Should the vertex data be interleaved into one VBO?
+       * @defaultValue `false`
+       */
+      interleaved: boolean | undefined | null;
+    }
   }
 }
+
+declare abstract class AnyPolygonMesher extends PolygonMesher {
+  constructor(arg0: never, ...args: never[]);
+}
diff --git a/src/foundry/client/pixi/core/shapes/precise-text.d.mts b/src/foundry/client/pixi/core/shapes/precise-text.d.mts
index 01ea32ba0..c59e584af 100644
--- a/src/foundry/client/pixi/core/shapes/precise-text.d.mts
+++ b/src/foundry/client/pixi/core/shapes/precise-text.d.mts
@@ -1,4 +1,4 @@
-export {};
+import type { InexactPartial, NullishProps } from "fvtt-types/utils";
 
 declare global {
   /**
@@ -6,22 +6,40 @@ declare global {
    * At default resolution Text often looks blurry or fuzzy.
    */
   class PreciseText extends PIXI.Text {
-    /**
-     * @param options - Additional options merged with the default TextStyle
-     */
     constructor(...args: ConstructorParameters<typeof PIXI.Text>);
 
+    /** @defaultValue `false` */
+    override _autoResolution: boolean;
+
+    /** @defaultValue `2` */
+    override _resolution: number;
     /**
      * Prepare a TextStyle object which merges the canvas defaults with user-provided options
      * @param anchor  - A text anchor point from CONST.TEXT_ANCHOR_POINTS
      * @param options - Additional options merged with the default TextStyle
      * @returns The prepared TextStyle
      */
-    static getTextStyle({
-      anchor,
-      ...options
-    }?: { anchor?: foundry.CONST.TEXT_ANCHOR_POINTS } & ConstructorParameters<
-      typeof PIXI.TextStyle
-    >[0]): PIXI.TextStyle;
+    static getTextStyle({ anchor, ...options }?: PreciseText.GetTextStyleOptions): PIXI.TextStyle;
   }
+
+  namespace PreciseText {
+    interface Any extends AnyPreciseText {}
+    type AnyConstructor = typeof AnyPreciseText;
+
+    /** @internal */
+    type _GetTextStyleOptions = NullishProps<{
+      /**
+       * A text anchor point from CONST.TEXT_ANCHOR_POINTS
+       * @remarks Only checked againt `.RIGHT` and `.LEFT`, and only if an `align` key is omitted
+       */
+      anchor: foundry.CONST.TEXT_ANCHOR_POINTS;
+    }> &
+      // Can't be NullishProps because keys are only checked for `!== undefined` in PIXI
+      InexactPartial<PIXI.ITextStyle>;
+    interface GetTextStyleOptions extends _GetTextStyleOptions {}
+  }
+}
+
+declare abstract class AnyPreciseText extends PreciseText {
+  constructor(arg0: never, ...args: never[]);
 }
diff --git a/src/foundry/client/pixi/core/shapes/ray.d.mts b/src/foundry/client/pixi/core/shapes/ray.d.mts
index 66a3211a0..7dc3c9764 100644
--- a/src/foundry/client/pixi/core/shapes/ray.d.mts
+++ b/src/foundry/client/pixi/core/shapes/ray.d.mts
@@ -71,14 +71,14 @@ declare global {
     /**
      * The cached angle, computed lazily in Ray#angle
      * @defaultValue `undefined`
-     * @internal
+     * @privateRemarks Foundry marked `@private` and doesn't type the `| undefined`
      */
     protected _angle: number | undefined;
 
     /**
      * The cached distance, computed lazily in Ray#distance
      * @defaultValue `undefined`
-     * @internal
+     * @privateRemarks Foundry marked `@private` and doesn't type the `| undefined`
      */
     protected _distance: number | undefined;
 
@@ -87,10 +87,11 @@ declare global {
      * The angle is computed lazily (only if required) and cached.
      */
     get angle(): number;
-    set angle(value: number);
+
+    set angle(value);
 
     /**
-     * A bounding rectangle that encompasses the Ray
+     * A normalized bounding rectangle that encompasses the Ray
      */
     get bounds(): PIXI.Rectangle;
 
@@ -99,7 +100,8 @@ declare global {
      * The distance is computed lazily (only if required) and cached.
      */
     get distance(): number;
-    set distance(value: number);
+
+    set distance(value);
 
     /**
      * A factory method to construct a Ray from an origin point, an angle, and a distance
@@ -125,7 +127,7 @@ declare global {
      * @param t - The distance along the Ray
      * @returns The coordinates of the projected point
      */
-    project(t: number): { x: number; y: number };
+    project(t: number): PIXI.IPointData;
 
     /**
      * Create a Ray by projecting a certain distance towards a known point.
@@ -154,12 +156,28 @@ declare global {
      * @param distance - A distance the new ray should project, otherwise uses the same distance.
      * @returns A new Ray with an offset angle
      */
-    shiftAngle(angleOffset: number, distance?: number): Ray;
+    shiftAngle(
+      offset: number,
+      /**
+       * @defaultValue `this.distance`
+       * @remarks Default provided by `||`, so `0` is effectively `this.distance`
+       */
+      distance?: number | null,
+    ): Ray;
 
     /**
      * Find the point I[x,y] and distance t* on ray R(t) which intersects another ray
      * @see foundry.utils.lineLineIntersection
      */
-    intersectSegment(coords: [x0: number, y0: number, x1: number, y1: number]): LineIntersection | null;
+    intersectSegment(coords: Canvas.PairOfPointsArray): LineIntersection | null;
+  }
+
+  namespace Ray {
+    interface Any extends AnyRay {}
+    type AnyConstructor = typeof AnyRay;
   }
 }
+
+declare abstract class AnyRay extends Ray {
+  constructor(arg0: never, ...args: never[]);
+}
diff --git a/src/foundry/client/pixi/core/shapes/source-polygon.d.mts b/src/foundry/client/pixi/core/shapes/source-polygon.d.mts
index 6319965df..af3d361a5 100644
--- a/src/foundry/client/pixi/core/shapes/source-polygon.d.mts
+++ b/src/foundry/client/pixi/core/shapes/source-polygon.d.mts
@@ -1,24 +1,20 @@
-import type { InexactPartial, FixedInstanceType } from "fvtt-types/utils";
+import type { Brand, InexactPartial, NullishProps } from "fvtt-types/utils";
 import type PointEffectSourceMixin from "../../../../client-esm/canvas/sources/point-effect-source.d.mts";
 
 declare global {
-  interface PointSourcePolygonConfig extends PointSourcePolygon._Config {
-    /** The type of polygon being computed */
-    type: PointSourcePolygon.PolygonType;
-  }
-
   /**
    * An extension of the default PIXI.Polygon which is used to represent the line of sight for a point source.
    */
   abstract class PointSourcePolygon extends PIXI.Polygon {
+    /**
+     * @remarks This is protected because `new PointSourcePolygon` does not sufficiently initalize the class; Use the static `create` method instead.
+     */
+    protected constructor(...args: ConstructorParameters<typeof PIXI.Polygon>);
+
     /**
      * Customize how wall direction of one-way walls is applied
      */
-    static readonly WALL_DIRECTION_MODES: Readonly<{
-      NORMAL: 0;
-      REVERSED: 1;
-      BOTH: 2;
-    }>;
+    static WALL_DIRECTION_MODES: PointSourcePolygon.WallDirectionModes;
 
     /**
      * The rectangular bounds of this polygon
@@ -28,14 +24,15 @@ declare global {
 
     /**
      * The origin point of the source polygon.
+     * @remarks Not initalized to any value, but immediately set by `PointSourcePolygon#initalize`
      */
     origin: Canvas.Point;
 
     /**
      * The configuration of this polygon.
-     * @defaultValue `{}`
+     * @remarks Initialized as `{}` but immediately filled by `PointSourcePolygon#initalize`
      */
-    config: PointSourcePolygonConfig;
+    config: PointSourcePolygon.StoredConfig;
 
     /**
      * An indicator for whether this polygon is constrained by some boundary shape?
@@ -48,20 +45,18 @@ declare global {
      * @param origin     - The origin point to benchmark
      * @param config     - The polygon configuration to benchmark
      */
-    static benchmark(iterations: number, origin: Canvas.Point, config: PointSourcePolygonConfig): Promise<void>;
+    static benchmark(iterations: number, origin: Canvas.Point, config: PointSourcePolygon.Config): Promise<void>;
 
     /**
      * Compute the polygon given a point origin and radius
      * @param origin - The origin source point
      * @param config - Configuration options which customize the polygon computation
-     *                 (default: `{}`)
      * @returns The computed polygon instance
+     * @remarks Subclasses must implement a `.create` override to accurately type the return.
+     *
+     * Despite being a `={}` parameter, a `config` object with a valid `type` property must be passed
      */
-    static create<T extends PointSourcePolygon.AnyConstructor>(
-      this: T,
-      origin: Canvas.Point,
-      config?: Parameters<FixedInstanceType<NoInfer<T>>["initialize"]>[1],
-    ): FixedInstanceType<T>;
+    static create(origin: Canvas.Point, config: PointSourcePolygon.Config): unknown;
 
     /**
      * Create a clone of this polygon.
@@ -86,7 +81,7 @@ declare global {
      * @param origin - The provided polygon origin
      * @param config - The provided configuration object
      */
-    initialize(origin: Canvas.Point, config: PointSourcePolygonConfig): void;
+    initialize(origin: Canvas.Point, config: PointSourcePolygon.Config): void;
 
     /**
      * Apply a constraining boundary shape to an existing PointSourcePolygon.
@@ -96,12 +91,16 @@ declare global {
      * @param intersectionOptions - Options passed to the shape intersection method
      * @returns A new constrained polygon
      */
+    applyConstraint(constraint: PIXI.Polygon, intersectionOptions?: PIXI.Polygon.IntersectPolygonOptions): this;
+    applyConstraint(constraint: PIXI.Circle, intersectionOptions?: PIXI.Circle.WACIntersectPolygonOptions): this;
+    applyConstraint(constraint: PIXI.Circle, intersectionOptions?: PIXI.Circle.ClipperLibIntersectPolygonOptions): this;
+    applyConstraint(constraint: PIXI.Rectangle, intersectionOptions?: PIXI.Rectangle.WACIntersectPolygonOptions): this;
     applyConstraint(
-      constraint: PIXI.Circle | PIXI.Rectangle | PIXI.Polygon,
-      intersectionOptions?: Record<string, unknown>,
-    ): PointSourcePolygon;
+      constraint: PIXI.Rectangle,
+      intersectionOptions?: PIXI.Rectangle.ClipperLibIntersectPolygonOptions,
+    ): this;
 
-    contains(x: number, y: number): boolean;
+    override contains(x: number, y: number): boolean;
 
     /**
      * Constrain polygon points by applying boundary shapes.
@@ -124,18 +123,7 @@ declare global {
     static testCollision<Mode extends PointSourcePolygon.CollisionModes>(
       origin: Canvas.Point,
       destination: Canvas.Point,
-      {
-        mode,
-
-        /** The configuration that defines a certain Polygon type */
-        ...config
-      }: {
-        /**
-         * The collision mode to test: "any", "all", or "closest"
-         * (default: "all")
-         */
-        mode?: Mode;
-      } & PointSourcePolygonConfig,
+      { mode, ...config }: PointSourcePolygon.TestCollisionConfig<Mode>,
     ): PointSourcePolygon.TestCollision<Mode>;
 
     /**
@@ -165,8 +153,9 @@ declare global {
      * Augment a PointSourcePolygon by adding additional coverage for shapes permitted by threshold walls.
      * @param polygon - The computed polygon
      * @returns The augmented polygon
+     * @remarks Mutates and returns the same reference it's passed, not a new polygon
      */
-    static applyThresholdAttenuation(polygon: PointSourcePolygon): PointSourcePolygon;
+    static applyThresholdAttenuation<PolyType extends PointSourcePolygon>(polygon: PolyType): PolyType;
 
     /**
      * @deprecated since v11, will be removed in v13
@@ -179,24 +168,109 @@ declare global {
   }
 
   namespace PointSourcePolygon {
+    interface Any extends AnyPointSourcePolygon {}
     type AnyConstructor = typeof AnyPointSourcePolygon;
 
+    type WALL_DIRECTION_MODES = Brand<number, "PointSourcePolygon.WALL_DIRECTION_MODES">;
+
+    interface WallDirectionModes {
+      readonly NORMAL: 0 & WALL_DIRECTION_MODES;
+      readonly REVERSED: 1 & WALL_DIRECTION_MODES;
+      readonly BOTH: 2 & WALL_DIRECTION_MODES;
+    }
+
     /** @internal */
-    type _Config = InexactPartial<{
-      /** The angle of emission, if limited */
-      angle: number;
+    type _TestCollisionConfig<Mode> = InexactPartial<{
+      /**
+       * The collision mode to test: "any", "all", or "closest"
+       * @defaultValue `"all"`
+       * @remarks Can't be `null` as it only has a parameter default
+       */
+      mode: Mode;
+    }>;
 
-      /** The desired density of padding rays, a number per PI */
-      density: number;
+    interface TestCollisionConfig<Mode> extends _TestCollisionConfig<Mode>, Config {}
+
+    /**
+     * @internal
+     * @privateRemarks Properties of the config that get set in `#initialize` or elsewhere with no respect to their passed value
+     */
+    interface _ComputedConfig {
+      /**
+       * Does this polygon have a limited radius?
+       * @remarks `true` if `(cfg.radius > 0) && (cfg.radius < canvas.dimensions.maxR)`
+       */
+      hasLimitedRadius: boolean;
+
+      /**
+       * Does this polygon have a limited angle?
+       * @remarks `true` if `cfg.angle !== 360`
+       */
+      hasLimitedAngle: boolean;
+    }
+
+    /**
+     * @internal
+     * @privateRemarks Properties of the config that might be omitted but can't be explicitly `undefined`
+     */
+    interface _OptionalOnlyConfig {
+      /**
+       * The object (if any) that spawned this polygon.
+       * @remarks Not guaranteed by `PointSourcePolygon#initalize` but will exist in all configs created by `PointEffectSourceMixin` subclasses. No default provided
+       * @privateRemarks Foundry types this as `PointSource` which is neither a typedef nor a class, not even a mixin class name. The type here matches usage and tracks with what they probably meant.
+       */
+      source?: PointEffectSourceMixin.AnyMixed;
+
+      /**
+       * The external radius of the source
+       * @remarks Can't be `undefined` or `null` or its use in math would produce `NaN`s.
+       *
+       * Not guaranteed by `PointSourcePolygon#initalize` but will exist in all configs created by `PointEffectSourceMixin` subclasses.
+       */
+      externalRadius?: number;
+    }
 
-      /** A limited radius of the resulting polygon */
+    /**
+     * @internal
+     * @privateRemarks Properties of the config that have defaults for nullish values in `#initialize`, and thus are guaranteed in the stored config
+     */
+    interface _BaseConfig {
+      /**
+       * A limited radius of the resulting polygon
+       * @defaultValue `canvas.dimensions.maxR`
+       */
       radius: number;
 
-      /** The direction of facing, required if the angle is limited */
+      /**
+       * The desired density of padding rays, a number per PI
+       * @defaultValue `PIXI.Circle.approximateVertexDensity(cfg.radius)`
+       */
+      density: number;
+
+      /**
+       * The angle of emission, if limited
+       * @defaultValue `360`
+       */
+      angle: number;
+
+      /**
+       * The direction of facing, required if the angle is limited
+       * @defaultValue `0`
+       */
       rotation: number;
 
-      /** Customize how wall direction of one-way walls is applied */
-      wallDirectionMode: number;
+      /**
+       * Does this polygon use the Scene inner or outer bounding rectangle
+       * @defaultValue `true` if `type === "sight"` and the origin point is inside `canvas.dimensions.sceneRect` else `false`
+       * @remarks Computed if not provided or passed nullish.
+       */
+      useInnerBounds: boolean;
+
+      /**
+       * Customize how wall direction of one-way walls is applied
+       * @defaultValue `PointSourcePolygon.WALL_DIRECTION_MODES.NORMAL`
+       */
+      wallDirectionMode: PointSourcePolygon.WALL_DIRECTION_MODES;
 
       /**
        * Compute the polygon with threshold wall constraints applied
@@ -210,42 +284,53 @@ declare global {
        */
       includeDarkness: boolean;
 
-      /** Priority when it comes to ignore edges from darkness sources */
-      priority: number;
-
-      /** Display debugging visualization and logging for the polygon */
-      debug: boolean;
+      /**
+       * Limiting polygon boundary shapes
+       * @defaultValue `[]`
+       * @remarks Never passed in Foundry practice
+       */
+      boundaryShapes: Array<BoundaryShapes>;
 
-      /** The object (if any) that spawned this polygon. */
-      source: PointEffectSourceMixin.AnyMixed;
+      /**
+       * Display debugging visualization and logging for the polygon
+       * @remarks Overriden `true` if `CONFIG.debug.polygons` is truthy
+       */
+      debug?: boolean;
 
-      /** Limiting polygon boundary shapes */
-      boundaryShapes: Array<PIXI.Rectangle | PIXI.Circle | PIXI.Polygon>;
+      /**
+       * Priority when it comes to ignore edges from darkness sources
+       * @remarks This is listed in the typedef, but is not in use by Foundry in 12.331
+       */
+      priority?: number;
+    }
 
-      /** Does this polygon use the Scene inner or outer bounding rectangle */
-      readonly useInnerBounds: boolean;
+    /**
+     * @internal
+     * @privateRemarks The only property required in all configs
+     */
+    interface _RequiredConfig {
+      /** The type of polygon being computed */
+      type: PolygonType;
+    }
 
-      /** Does this polygon have a limited radius? */
-      readonly hasLimitedRadius: boolean;
+    interface StoredConfig extends _RequiredConfig, _BaseConfig, _OptionalOnlyConfig, _ComputedConfig {}
 
-      /** Does this polygon have a limited angle? */
-      readonly hasLimitedAngle: boolean;
+    interface Config extends _RequiredConfig, NullishProps<_BaseConfig>, _OptionalOnlyConfig {}
 
-      /** The computed bounding box for the polygon */
-      readonly boundingBox: PIXI.Rectangle;
-    }>;
+    type BoundaryShapes = PIXI.Rectangle | PIXI.Circle | PIXI.Polygon;
 
     type PolygonType = "light" | "sight" | "sound" | "move" | "universal";
 
     type CollisionModes = "any" | "all" | "closest";
 
-    interface CollisionTypes {
+    /** @internal */
+    interface _CollisionTypesReturnMap {
       any: boolean;
-      closest: foundry.canvas.edges.PolygonVertex;
-      all: foundry.canvas.edges.PolygonVertex[] | null;
+      closest: foundry.canvas.edges.PolygonVertex | null;
+      all: foundry.canvas.edges.PolygonVertex[];
     }
 
-    type TestCollision<Mode extends CollisionModes> = CollisionTypes[Mode];
+    type TestCollision<Mode extends CollisionModes> = _CollisionTypesReturnMap[Mode];
   }
 }
 
diff --git a/src/foundry/client/pixi/extensions/polygon.d.mts b/src/foundry/client/pixi/extensions/polygon.d.mts
index 947b0bd44..6ab369c4e 100644
--- a/src/foundry/client/pixi/extensions/polygon.d.mts
+++ b/src/foundry/client/pixi/extensions/polygon.d.mts
@@ -70,7 +70,7 @@ declare global {
        * @param options - Options which configure how the intersection is computed
        * @returns The intersected polygon
        */
-      intersectPolygon(other: PIXI.Polygon, options?: PIXI.Polygon.IntersectClipperOptions): PIXI.Polygon;
+      intersectPolygon(other: PIXI.Polygon, options?: PIXI.Polygon.IntersectPolygonOptions): PIXI.Polygon;
 
       /**
        * Intersect this PIXI.Polygon with an array of ClipperPoints.
@@ -108,6 +108,9 @@ declare global {
     }
 
     namespace Polygon {
+      type OrPointsFlat = number[] | PIXI.Polygon;
+      type OrPoints = OrPointsFlat | PIXI.IPointData[];
+
       /** @privateRemarks Foundry uses this type instead of full `ClipperLib.IntPoint` objects */
       interface ClipperPoint {
         X: number;
@@ -134,6 +137,12 @@ declare global {
 
       interface IntersectClipperOptions extends _IntersectClipperOptions {}
 
+      /**
+       * @privateRemarks Separate interface despite identical keys for purposes of declaration merging
+       * and just having an expected name for external reference
+       */
+      interface IntersectPolygonOptions extends _IntersectClipperOptions {}
+
       interface ClipperPointsOptions extends Pick<PIXI.Polygon.IntersectClipperOptions, "scalingFactor"> {}
     }
 
diff --git a/src/foundry/client/pixi/perception/clockwise-sweep.d.mts b/src/foundry/client/pixi/perception/clockwise-sweep.d.mts
index de9658fc7..6d3b6a75e 100644
--- a/src/foundry/client/pixi/perception/clockwise-sweep.d.mts
+++ b/src/foundry/client/pixi/perception/clockwise-sweep.d.mts
@@ -1,12 +1,15 @@
+import type { IntentionalPartial } from "fvtt-types/utils";
 import type Edge from "../../../client-esm/canvas/edges/edge.d.mts";
 
 declare global {
-  type VertexMap = Map<number, foundry.canvas.edges.PolygonVertex>;
-
-  type EdgeSet = Set<Edge>;
-
   interface PolygonRay extends Ray {
-    result: foundry.canvas.edges.CollisionResult;
+    /**
+     * @remarks Only set in `ClockwiseSweepPolygon#_switchEdge` and only consumed in `#visualize`,
+     * despite unrelated method(s) having parameters claiming to want a `PolygonRay`
+     *
+     * Tested for truthiness in `#visualize` before use, so a nullish value is fine but never attains in core
+     */
+    result?: foundry.canvas.edges.CollisionResult | undefined | null;
   }
 
   /**
@@ -15,15 +18,21 @@ declare global {
    * This algorithm was created with valuable contributions from https://github.com/caewok
    */
   class ClockwiseSweepPolygon extends PointSourcePolygon {
+    // This does not appear in Foundry code, it's a necessary type override
+    static override create(origin: Canvas.Point, config: PointSourcePolygon.Config): ClockwiseSweepPolygon;
+
+    // This does not appear in foundry code, it's a necessary type override
+    override config: ClockwiseSweepPolygon.StoredConfig;
+
     /**
      * A mapping of vertices which define potential collision points
      */
-    vertices: VertexMap;
+    vertices: Map<number, foundry.canvas.edges.PolygonVertex>;
 
     /**
      * The set of edges which define potential boundaries of the polygon
      */
-    edges: EdgeSet;
+    edges: Set<Edge>;
 
     /**
      * A collection of rays which are fired at vertices
@@ -31,7 +40,7 @@ declare global {
     // @ts-expect-error Getter/setter routine is deprecated functionality as of v11, removed in v13
     rays: PolygonRay[];
 
-    override initialize(origin: Canvas.Point, config: PointSourcePolygonConfig): void;
+    override initialize(origin: Canvas.Point, config?: PointSourcePolygon.Config): void;
 
     clone(): this;
 
@@ -46,7 +55,7 @@ declare global {
     /**
      * Determine the edge types and their manner of inclusion for this polygon instance
      */
-    protected _determineEdgeTypes(): Record<Edge.EdgeTypes, 0 | 1 | 2>;
+    protected _determineEdgeTypes(): ClockwiseSweepPolygon.DetermineEdgesReturn;
 
     /**
      * Test whether a wall should be included in the computed polygon for a given origin and type
@@ -57,7 +66,7 @@ declare global {
      */
     protected _testEdgeInclusion(
       edge: Edge,
-      edgeTypes: Record<Edge.EdgeTypes, 0 | 1 | 2>,
+      edgeTypes: ClockwiseSweepPolygon.DetermineEdgesReturn,
       bounds: PIXI.Rectangle,
     ): boolean;
 
@@ -75,25 +84,25 @@ declare global {
     /**
      * Add additional vertices for intersections between edges.
      */
-    protected _identifyIntersections(wallEdgeMap: Map<string, Edge>): void;
+    protected _identifyIntersections(edgeMap: Map<string, Edge>): void;
 
     /**
      * Execute the sweep over wall vertices
-     * @internal
+     * @privateRemarks Foundry marked `@private`
      */
     protected _executeSweep(): void;
 
     /**
      * Determine the initial set of active edges as those which intersect with the initial ray
      * @returns A set of initially active edges
-     * @internal
+     * @privateRemarks Foundry marked `@private`
      */
-    protected _initializeActiveEdges(): EdgeSet;
+    protected _initializeActiveEdges(): Set<Edge>;
 
     /**
      * Sort vertices clockwise from the initial ray (due west).
      * @returns The array of sorted vertices
-     * @internal
+     * @privateRemarks Foundry marked `@private`
      */
     protected _sortVertices(): foundry.canvas.edges.PolygonVertex[];
 
@@ -105,11 +114,11 @@ declare global {
      * @param vertex      - The target vertex
      * @param activeEdges - The set of active edges
      * @returns Is the target vertex behind some closer edge?
-     * @internal
+     * @privateRemarks Foundry marked `@private`
      */
     protected _isVertexBehindActiveEdges(
       vertex: foundry.canvas.edges.PolygonVertex,
-      activeEdges: EdgeSet,
+      activeEdges: Set<Edge>,
     ): { isBehind: boolean; wasLimited: boolean };
 
     /**
@@ -117,12 +126,13 @@ declare global {
      * @param vertex        - The target vertex
      * @param activeEdges   - The set of active edges
      * @param hasCollinear  - Are there collinear vertices behind the target vertex?
-     * @internal
+     *                        default: `false`
+     * @privateRemarks Foundry marked `@private`
      */
     protected _determineSweepResult(
       vertex: foundry.canvas.edges.PolygonVertex,
-      activeEdges: EdgeSet,
-      hasCollinear: boolean,
+      activeEdges: Set<Edge>,
+      hasCollinear?: boolean,
     ): void;
 
     /**
@@ -134,24 +144,43 @@ declare global {
      *
      * If neither side is blocked and the ray internally collides with a non-limited edge, n skip without adding polygon
      * endpoints. Sight is unaffected before this edge, and the internal collision can be ignored.
-     * @internal
      *
      * @param result      - The pending collision result
      * @param activeEdges - The set of currently active edges
+     * @privateRemarks Foundry marked `@private`
      */
-    _switchEdge(result: foundry.canvas.edges.CollisionResult, activeEdges: EdgeSet): void;
+    protected _switchEdge(result: foundry.canvas.edges.CollisionResult, activeEdges: Set<Edge>): void;
 
     protected override _testCollision<Mode extends PointSourcePolygon.CollisionModes>(
       ray: Ray,
       mode: Mode,
     ): PointSourcePolygon.TestCollision<Mode>;
 
-    override visualize(): PIXI.Graphics | undefined;
+    override visualize(): PIXI.Graphics;
 
     /**
      * Visualize the polygon, displaying its computed area, rays, and collision points
-     * @internal
+     * @privateRemarks Foundry marked `@private`
      */
     protected _visualizeCollision(ray: Ray, collisions: foundry.canvas.edges.PolygonVertex[]): void;
   }
+
+  namespace ClockwiseSweepPolygon {
+    interface Any extends AnyClockwiseSweepPolygon {}
+    type AnyConstructor = typeof AnyClockwiseSweepPolygon;
+
+    interface StoredConfig extends PointSourcePolygon.StoredConfig {
+      /** The computed bounding box for the polygon */
+      boundingBox: PIXI.Rectangle;
+    }
+    /**
+     * @privateRemarks Foundry types this as `Record<Edge.EdgeTypes, 0 | 1 | 2>`, but some keys are mutually exclusive,
+     * and none are ever set to `0`, they're simply omitted and then tested for truthiness in `#_testEdgeInclusion`
+     */
+    type DetermineEdgesReturn = IntentionalPartial<Record<Edge.EdgeTypes, 1 | 2>>;
+  }
+}
+
+declare abstract class AnyClockwiseSweepPolygon extends ClockwiseSweepPolygon {
+  constructor(arg0: never, ...args: never[]);
 }


Test patch:
diff --git a/tests/foundry/client-esm/canvas/edges/collision.test-d.ts b/tests/foundry/client-esm/canvas/edges/collision.test-d.ts
index 65da3d6ed..ab3e03073 100644
--- a/tests/foundry/client-esm/canvas/edges/collision.test-d.ts
+++ b/tests/foundry/client-esm/canvas/edges/collision.test-d.ts
@@ -4,7 +4,7 @@ const myCollisionResult = new foundry.canvas.edges.CollisionResult();
 
 expectTypeOf(myCollisionResult.target).toEqualTypeOf<foundry.canvas.edges.PolygonVertex | null>();
 expectTypeOf(myCollisionResult.collisions).toEqualTypeOf<foundry.canvas.edges.PolygonVertex[]>();
-expectTypeOf(myCollisionResult.cwEdges).toEqualTypeOf<EdgeSet>();
+expectTypeOf(myCollisionResult.cwEdges).toEqualTypeOf<Set<foundry.canvas.edges.Edge>>();
 expectTypeOf(myCollisionResult.isBehind).toEqualTypeOf<boolean | undefined>();
 expectTypeOf(myCollisionResult.isLimited).toEqualTypeOf<boolean | undefined>();
 expectTypeOf(myCollisionResult.wasLimited).toEqualTypeOf<boolean | undefined>();
diff --git a/tests/foundry/client-esm/canvas/edges/vertex.test-d.ts b/tests/foundry/client-esm/canvas/edges/vertex.test-d.ts
index f2e66b30e..9f7f81961 100644
--- a/tests/foundry/client-esm/canvas/edges/vertex.test-d.ts
+++ b/tests/foundry/client-esm/canvas/edges/vertex.test-d.ts
@@ -5,9 +5,9 @@ const vertex = new foundry.canvas.edges.PolygonVertex(2, 2);
 expectTypeOf(vertex.x).toEqualTypeOf<number>();
 expectTypeOf(vertex.y).toEqualTypeOf<number>();
 expectTypeOf(vertex.key).toEqualTypeOf<number>();
-expectTypeOf(vertex.edges).toEqualTypeOf<EdgeSet>();
-expectTypeOf(vertex.cwEdges).toEqualTypeOf<EdgeSet>();
-expectTypeOf(vertex.ccwEdges).toEqualTypeOf<EdgeSet>();
+expectTypeOf(vertex.edges).toEqualTypeOf<Set<foundry.canvas.edges.Edge>>();
+expectTypeOf(vertex.cwEdges).toEqualTypeOf<Set<foundry.canvas.edges.Edge>>();
+expectTypeOf(vertex.ccwEdges).toEqualTypeOf<Set<foundry.canvas.edges.Edge>>();
 expectTypeOf(vertex.collinearVertices).toEqualTypeOf<Set<foundry.canvas.edges.PolygonVertex>>();
 expectTypeOf(vertex.type).toEqualTypeOf<number | null>();
 expectTypeOf(vertex.isEndpoint).toEqualTypeOf<boolean | undefined>();
diff --git a/tests/foundry/client/pixi/core/shapes/limited-angle-polygon.test-d.ts b/tests/foundry/client/pixi/core/shapes/limited-angle-polygon.test-d.ts
index 1d3d9cb56..042d6fe54 100644
--- a/tests/foundry/client/pixi/core/shapes/limited-angle-polygon.test-d.ts
+++ b/tests/foundry/client/pixi/core/shapes/limited-angle-polygon.test-d.ts
@@ -1,9 +1,17 @@
 import { expectTypeOf } from "vitest";
 
 const myPoint = new PIXI.Point(2, 2);
+declare const someRay: Ray;
+
+expectTypeOf(LimitedAnglePolygon.pointBetweenRays(myPoint, someRay, someRay, 30)).toEqualTypeOf<boolean>();
 
 const myLimitedAnglePolygon = new LimitedAnglePolygon(myPoint, {
   radius: 1,
+  angle: 90,
+  rotation: 45,
+  density: 2,
+  externalRadius: 180,
 });
 
 expectTypeOf(myLimitedAnglePolygon.getBounds()).toEqualTypeOf<PIXI.Rectangle>();
+expectTypeOf(myLimitedAnglePolygon._includeEdge({ x: 50, y: 50 }, { x: 100, y: 100 })).toEqualTypeOf<boolean>();
diff --git a/tests/foundry/client/pixi/core/shapes/polygon-mesher.test-d.ts b/tests/foundry/client/pixi/core/shapes/polygon-mesher.test-d.ts
index 727fa8bba..837e12ad1 100644
--- a/tests/foundry/client/pixi/core/shapes/polygon-mesher.test-d.ts
+++ b/tests/foundry/client/pixi/core/shapes/polygon-mesher.test-d.ts
@@ -1,7 +1,20 @@
 import { expectTypeOf } from "vitest";
 
-const myPolygonMesher = new PolygonMesher([1, 2]);
+declare const somePoly: PIXI.Polygon;
+declare const someGometry: PIXI.Geometry;
 
-const myGeometry = new PIXI.Geometry();
+expectTypeOf(PolygonMesher.getClipperPathFromPoints(somePoly, 3)).toEqualTypeOf<ClipperLib.Path>();
 
-expectTypeOf(myPolygonMesher.triangulate(myGeometry)).toEqualTypeOf<PIXI.Geometry>();
+const myPolygonMesher = new PolygonMesher([1, 2, 3, 4], {
+  depthInner: null,
+  depthOuter: 7,
+  interleaved: true,
+  miterLimit: undefined,
+  normalize: null,
+  offset: 50,
+  radius: 200,
+  x: 202,
+  y: 303,
+});
+
+expectTypeOf(myPolygonMesher.triangulate(someGometry)).toEqualTypeOf<PIXI.Geometry>();
diff --git a/tests/foundry/client/pixi/core/shapes/precise-text.test-d.ts b/tests/foundry/client/pixi/core/shapes/precise-text.test-d.ts
index 562d800c2..996e4fea9 100644
--- a/tests/foundry/client/pixi/core/shapes/precise-text.test-d.ts
+++ b/tests/foundry/client/pixi/core/shapes/precise-text.test-d.ts
@@ -1,5 +1,17 @@
 import { expectTypeOf } from "vitest";
 
-const myPreciseText = new PreciseText("foobar", PreciseText.getTextStyle());
+let textStyle;
+expectTypeOf(
+  (textStyle = PreciseText.getTextStyle({
+    anchor: CONST.TEXT_ANCHOR_POINTS.LEFT,
+    fillGradientStops: [4, 5, 6, 1, 23, 4],
+    padding: 5,
+    wordWrap: true,
+    fontVariant: "small-caps",
+  })),
+);
+const myPreciseText = new PreciseText("foobar", textStyle);
 
 expectTypeOf(myPreciseText.anchor.set(0, 1)).toEqualTypeOf<PIXI.ObservablePoint>();
+expectTypeOf(myPreciseText._autoResolution).toEqualTypeOf<boolean>();
+expectTypeOf(myPreciseText._resolution).toEqualTypeOf<number>();
diff --git a/tests/foundry/client/pixi/core/shapes/ray.test-d.ts b/tests/foundry/client/pixi/core/shapes/ray.test-d.ts
index 81a702f89..751c411a2 100644
--- a/tests/foundry/client/pixi/core/shapes/ray.test-d.ts
+++ b/tests/foundry/client/pixi/core/shapes/ray.test-d.ts
@@ -1,5 +1,11 @@
 import { expectTypeOf } from "vitest";
+import type { LineIntersection } from "../../../../../../src/foundry/common/utils/geometry.d.mts";
 
-const myRay = Ray.towardsPoint({ x: 0, y: 0 }, { x: 1, y: 1 }, 5);
+let myRay = Ray.towardsPoint({ x: 0, y: 0 }, { x: 1, y: 1 }, 5);
+myRay = Ray.fromAngle(50, 50, Math.PI / 2, 200);
+myRay = Ray.fromArrays([50, 50], [100, 100]);
 
-expectTypeOf(myRay.project(7)).toEqualTypeOf<{ x: number; y: number }>();
+expectTypeOf(myRay.project(7)).toEqualTypeOf<PIXI.IPointData>();
+expectTypeOf(myRay.reverse()).toEqualTypeOf<Ray>();
+expectTypeOf(myRay.shiftAngle(20, 2000)).toEqualTypeOf<Ray>();
+expectTypeOf(myRay.intersectSegment([30, 40, 90, 100])).toEqualTypeOf<LineIntersection | null>();
diff --git a/tests/foundry/client/pixi/perception/clockwise-sweep.test-d.ts b/tests/foundry/client/pixi/perception/clockwise-sweep.test-d.ts
index 14b6d64aa..927a3989e 100644
--- a/tests/foundry/client/pixi/perception/clockwise-sweep.test-d.ts
+++ b/tests/foundry/client/pixi/perception/clockwise-sweep.test-d.ts
@@ -1,12 +1,80 @@
 import { expectTypeOf } from "vitest";
+import type PolygonVertex from "../../../../../src/foundry/client-esm/canvas/edges/vertex.d.mts";
 
 const pointA = new PIXI.Point(0, 0);
 const pointB = new PIXI.Point(0, 0);
+declare const someRect: PIXI.Rectangle;
+declare const somePoly: PIXI.Polygon;
+declare const someCircle: PIXI.Circle;
+declare const someEdge: foundry.canvas.edges.Edge;
+declare const somePV: foundry.canvas.edges.PolygonVertex;
 
-expectTypeOf(ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "any" })).toEqualTypeOf<boolean>();
-expectTypeOf(ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "closest" })).toEqualTypeOf<PolygonVertex>();
-expectTypeOf(ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "all" })).toEqualTypeOf<
-  PolygonVertex[] | null
+expectTypeOf(
+  ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "any", type: "light" }),
+).toEqualTypeOf<boolean>();
+expectTypeOf(
+  ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "closest", type: "sound" }),
+).toEqualTypeOf<PolygonVertex | null>();
+expectTypeOf(ClockwiseSweepPolygon.testCollision(pointA, pointB, { mode: "all", type: "move" })).toEqualTypeOf<
+  PolygonVertex[]
 >();
 
-expectTypeOf(ClockwiseSweepPolygon.create({ x: 0, y: 0 })).toEqualTypeOf<ClockwiseSweepPolygon>();
+let myCSP;
+expectTypeOf(
+  (myCSP = ClockwiseSweepPolygon.create(
+    { x: 0, y: 0 },
+    {
+      type: "light",
+    },
+  )),
+).toEqualTypeOf<ClockwiseSweepPolygon>();
+
+expectTypeOf(
+  myCSP.applyConstraint(somePoly, {
+    clipType: ClipperLib.ClipType.ctXor,
+    scalingFactor: 4,
+  }),
+).toEqualTypeOf<typeof myCSP>();
+
+expectTypeOf(
+  myCSP.applyConstraint(someRect, {
+    weilerAtherton: false,
+    clipType: ClipperLib.ClipType.ctDifference,
+    scalingFactor: 2,
+  }),
+).toEqualTypeOf<typeof myCSP>();
+expectTypeOf(
+  myCSP.applyConstraint(someRect, {
+    weilerAtherton: true,
+    canMutate: false,
+    clipType: WeilerAthertonClipper.CLIP_TYPES.INTERSECT,
+  }),
+).toEqualTypeOf<typeof myCSP>();
+
+expectTypeOf(
+  myCSP.applyConstraint(someCircle, {
+    weilerAtherton: false,
+    clipType: ClipperLib.ClipType.ctUnion,
+    scalingFactor: 2,
+  }),
+).toEqualTypeOf<typeof myCSP>();
+expectTypeOf(
+  myCSP.applyConstraint(someCircle, {
+    weilerAtherton: true,
+    clipType: ClipperLib.ClipType.ctIntersection,
+    canMutate: null,
+  }),
+).toEqualTypeOf<typeof myCSP>();
+
+expectTypeOf(myCSP.contains(50, 100)).toEqualTypeOf<boolean>();
+expectTypeOf(myCSP["_testEdgeInclusion"](someEdge, { wall: 1, innerBounds: 2 }, someRect)).toEqualTypeOf<boolean>();
+
+const edgeMap = new Map([["bob", someEdge]]);
+const edgeSet = new Set([someEdge]);
+
+expectTypeOf(myCSP["_identifyIntersections"](edgeMap)).toEqualTypeOf<void>();
+expectTypeOf(myCSP["_isVertexBehindActiveEdges"](somePV, edgeSet)).toEqualTypeOf<{
+  isBehind: boolean;
+  wasLimited: boolean;
+}>();
+expectTypeOf(myCSP["_determineSweepResult"](somePV, edgeSet, false)).toEqualTypeOf<void>();
diff --git a/tests/foundry/public/scripts/clipper/clipper.test-d.ts b/tests/foundry/public/scripts/clipper/clipper.test-d.ts
index f862c18e4..c39a53c3b 100644
--- a/tests/foundry/public/scripts/clipper/clipper.test-d.ts
+++ b/tests/foundry/public/scripts/clipper/clipper.test-d.ts
@@ -29,3 +29,9 @@ expectTypeOf(
 ).toEqualTypeOf<boolean>();
 expectTypeOf(clipper.Execute(ClipperLib.ClipType.ctDifference, polyTree)).toEqualTypeOf<boolean>();
 expectTypeOf(clipper.Execute(ClipperLib.ClipType.ctDifference, paths)).toEqualTypeOf<boolean>();
+
+const clipperOffset = new ClipperLib.ClipperOffset(20, 0.25);
+
+expectTypeOf(
+  clipperOffset.AddPath(paths[0], ClipperLib.JoinType.jtMiter, ClipperLib.EndType.etClosedPolygon),
+).toEqualTypeOf<void>();