Skip to content

Commit

Permalink
Use GetDataReturnType in GridConfig (#2797)
Browse files Browse the repository at this point in the history
* Use `GetDataReturnType` in `GridConfig`

## What issue does this pull request correspond to (if any)?

Part of #2546

## What does this pull request implement?

We migrate `GridConfig#getData` to use `GetDataReturnType`. We're
following the pattern laid out in the other subclasses of `Application`.

## What changes are made in this pull request?

- Addition: Added `GridConfig.GridConfigData`.
- Breaking: The return type of `GridConfig#getData` is more precise now.

* Use `Scene.ConfiguredInstance`

Since the `Scene` can be overridden and extended by package developers,
we want to use a type that reflects what has been configured for the
`Scene`, rather than what is statically defined here in this package.
  • Loading branch information
joneshf authored Sep 15, 2024
1 parent 4f0679a commit 2e675ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/foundry/client/apps/forms/grid-config.d.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ConfiguredDocumentClass, InterfaceToObject } from "../../../../types/helperTypes.d.mts";
import type { AnyObject, MaybePromise } from "../../../../types/utils.d.mts";
import type { AnyObject, GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts";

declare global {
/**
Expand Down Expand Up @@ -38,7 +38,7 @@ declare global {

protected override _render(force?: boolean, options?: Application.RenderOptions<Options>): Promise<void>;

override getData(options?: Partial<Options>): MaybePromise<AnyObject>;
override getData(options?: Partial<Options>): MaybePromise<GetDataReturnType<GridConfig.GridConfigData>>;

protected override _getSubmitData(updateData?: AnyObject | null): InterfaceToObject<GridConfig.FormData>;

Expand Down Expand Up @@ -134,5 +134,11 @@ declare global {
"background.offsetX": Scene["background"]["offsetX"];
"background.offsetY": Scene["background"]["offsetY"];
}

interface GridConfigData {
gridTypes: Record<foundry.CONST.GRID_TYPES, string>;
scale: number;
scene: Scene.ConfiguredInstance;
}
}
}

0 comments on commit 2e675ef

Please sign in to comment.