Skip to content

Commit

Permalink
Fix some types associated with ApplicationV2 and `HandlebarsApplica…
Browse files Browse the repository at this point in the history
…tionMixin` (foundryvtt#16241)
  • Loading branch information
stwlam authored Aug 26, 2024
1 parent 65fa84f commit 57587d7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DataField } from "../../common/data/fields.d.ts";
import type { DataField } from "../../common/data/fields.js";

declare global {
interface ApplicationConfiguration {
Expand Down Expand Up @@ -95,6 +95,17 @@ declare global {
* @default false
*/
force?: boolean;
/** A specific position at which to render the Application */
position?: ApplicationPosition;
/** Updates to the Application window frame */
window?: ApplicationWindowRenderOptions;
/**
* Some Application classes, for example the HandlebarsApplication, support re-rendering a subset of application
* parts instead of the full Application HTML.
*/
parts?: string[];
/** Is this render the first one for the application? This property is populated automatically. */
isFirstRender?: boolean;
}

interface ApplicationWindowRenderOptions {
Expand All @@ -106,8 +117,6 @@ declare global {
controls: boolean;
}

interface ApplicationRenderContext {}

interface ApplicationClosingOptions {
/** Whether to animate the close, or perform it instantaneously */
animate?: boolean;
Expand Down
12 changes: 6 additions & 6 deletions types/foundry/client-esm/applications/api/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class ApplicationV2<
* @param options Options which configure application rendering behavior
* @returns Context data for the render operation
*/
protected _prepareContext(options: TRenderOptions): Promise<ApplicationRenderContext>;
protected _prepareContext(options: TRenderOptions): Promise<object>;

/**
* Configure the array of header control menu options
Expand All @@ -143,7 +143,7 @@ export default class ApplicationV2<
* @returns The result of HTML rendering may be implementation specific.
* Whatever value is returned here is passed to _replaceHTML
*/
protected _renderHTML(context: ApplicationRenderContext, options: TRenderOptions): Promise<unknown>;
protected _renderHTML(context: Record<string, unknown>, options: TRenderOptions): Promise<unknown>;

/**
* Replace the HTML of the application with the result provided by the rendering backend.
Expand Down Expand Up @@ -274,31 +274,31 @@ export default class ApplicationV2<
* @param context Prepared context data
* @param options Provided render options
*/
protected _preFirstRender(context: ApplicationRenderContext, options: TRenderOptions): Promise<void>;
protected _preFirstRender(context: Record<string, unknown>, options: TRenderOptions): Promise<void>;

/**
* Actions performed after a first render of the Application.
* Post-render steps are not awaited by the render process.
* @param context Prepared context data
* @param options Provided render options
*/
protected _onFirstRender(context: ApplicationRenderContext, options: TRenderOptions): void;
protected _onFirstRender(context: object, options: TRenderOptions): void;

/**
* Actions performed before any render of the Application.
* Pre-render steps are awaited by the render process.
* @param context Prepared context data
* @param options Provided render options
*/
protected _preRender(context: ApplicationRenderContext, options: TRenderOptions): Promise<void>;
protected _preRender(context: object, options: TRenderOptions): Promise<void>;

/**
* Actions performed after any render of the Application.
* Post-render steps are not awaited by the render process.
* @param context Prepared context data
* @param options Provided render options
*/
protected _onRender(context: ApplicationRenderContext, options: TRenderOptions): void;
protected _onRender(context: object, options: TRenderOptions): void;

/**
* Actions performed before closing the Application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function HandlebarsApplicationMixin<TBase extends ConstructorOf<A
* @returns A single rendered HTMLElement for each requested part
*/
protected override async _renderHTML(
context: ApplicationRenderContext,
context: object,
options: HandlebarsRenderOptions,
): Promise<Record<string, HTMLElement>> {
context;
Expand All @@ -38,10 +38,7 @@ export default function HandlebarsApplicationMixin<TBase extends ConstructorOf<A
* @param context Shared context provided by _prepareContext
* @returns Context data for a specific part
*/
protected async _preparePartContext(
partId: string,
context: ApplicationRenderContext,
): Promise<ApplicationRenderContext> {
protected async _preparePartContext(partId: string, context: object): Promise<object> {
partId;
context;
return {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ declare global {
type: string;
name: string;
img: ImageFilePath;
uuid: string;
uuid: CompendiumUUID;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}
Expand Down
5 changes: 4 additions & 1 deletion types/foundry/client/game.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ declare global {
};

/** The game World which is currently active */
world: object;
world: {
id: string;
title: string;
};

/** Localization support */
i18n: Localization;
Expand Down
2 changes: 1 addition & 1 deletion types/foundry/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./client-esm/applications/types.d.ts";
import "./client-esm/applications/_types.js";
import "./client/index.d.ts";
import "./common/grid/index.ts";
import "./common/module.d.ts";
Expand Down

0 comments on commit 57587d7

Please sign in to comment.