From 57587d746675618ede29bde3d02fd176b341fc3f Mon Sep 17 00:00:00 2001 From: Shark that walks like a man <106829671+stwlam@users.noreply.github.com> Date: Mon, 26 Aug 2024 06:08:00 -0500 Subject: [PATCH] Fix some types associated with `ApplicationV2` and `HandlebarsApplicationMixin` (#16241) --- .../applications/{types.d.ts => _types.d.ts} | 15 ++++++++++++--- .../client-esm/applications/api/application.d.ts | 12 ++++++------ .../applications/api/handlebars-application.ts | 7 ++----- .../data/collections/compendium-collection.d.ts | 2 +- types/foundry/client/game.d.ts | 5 ++++- types/foundry/index.d.ts | 2 +- 6 files changed, 26 insertions(+), 17 deletions(-) rename types/foundry/client-esm/applications/{types.d.ts => _types.d.ts} (88%) diff --git a/types/foundry/client-esm/applications/types.d.ts b/types/foundry/client-esm/applications/_types.d.ts similarity index 88% rename from types/foundry/client-esm/applications/types.d.ts rename to types/foundry/client-esm/applications/_types.d.ts index c3c191a8246..36fc0124064 100644 --- a/types/foundry/client-esm/applications/types.d.ts +++ b/types/foundry/client-esm/applications/_types.d.ts @@ -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 { @@ -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 { @@ -106,8 +117,6 @@ declare global { controls: boolean; } - interface ApplicationRenderContext {} - interface ApplicationClosingOptions { /** Whether to animate the close, or perform it instantaneously */ animate?: boolean; diff --git a/types/foundry/client-esm/applications/api/application.d.ts b/types/foundry/client-esm/applications/api/application.d.ts index 75c1cf66e96..af135ec1439 100644 --- a/types/foundry/client-esm/applications/api/application.d.ts +++ b/types/foundry/client-esm/applications/api/application.d.ts @@ -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; + protected _prepareContext(options: TRenderOptions): Promise; /** * Configure the array of header control menu options @@ -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; + protected _renderHTML(context: Record, options: TRenderOptions): Promise; /** * Replace the HTML of the application with the result provided by the rendering backend. @@ -274,7 +274,7 @@ export default class ApplicationV2< * @param context Prepared context data * @param options Provided render options */ - protected _preFirstRender(context: ApplicationRenderContext, options: TRenderOptions): Promise; + protected _preFirstRender(context: Record, options: TRenderOptions): Promise; /** * Actions performed after a first render of the Application. @@ -282,7 +282,7 @@ export default class ApplicationV2< * @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. @@ -290,7 +290,7 @@ export default class ApplicationV2< * @param context Prepared context data * @param options Provided render options */ - protected _preRender(context: ApplicationRenderContext, options: TRenderOptions): Promise; + protected _preRender(context: object, options: TRenderOptions): Promise; /** * Actions performed after any render of the Application. @@ -298,7 +298,7 @@ export default class ApplicationV2< * @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. diff --git a/types/foundry/client-esm/applications/api/handlebars-application.ts b/types/foundry/client-esm/applications/api/handlebars-application.ts index feb72187a7b..b9b4927aa7b 100644 --- a/types/foundry/client-esm/applications/api/handlebars-application.ts +++ b/types/foundry/client-esm/applications/api/handlebars-application.ts @@ -19,7 +19,7 @@ export default function HandlebarsApplicationMixin> { context; @@ -38,10 +38,7 @@ export default function HandlebarsApplicationMixin { + protected async _preparePartContext(partId: string, context: object): Promise { partId; context; return {}; diff --git a/types/foundry/client/data/collections/compendium-collection.d.ts b/types/foundry/client/data/collections/compendium-collection.d.ts index a50b572bc29..88705f42a6c 100644 --- a/types/foundry/client/data/collections/compendium-collection.d.ts +++ b/types/foundry/client/data/collections/compendium-collection.d.ts @@ -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; } diff --git a/types/foundry/client/game.d.ts b/types/foundry/client/game.d.ts index ea40a4d52aa..81d24a7e442 100644 --- a/types/foundry/client/game.d.ts +++ b/types/foundry/client/game.d.ts @@ -45,7 +45,10 @@ declare global { }; /** The game World which is currently active */ - world: object; + world: { + id: string; + title: string; + }; /** Localization support */ i18n: Localization; diff --git a/types/foundry/index.d.ts b/types/foundry/index.d.ts index 7c1627b4fed..fd4242dd4f2 100644 --- a/types/foundry/index.d.ts +++ b/types/foundry/index.d.ts @@ -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";