diff --git a/package.json b/package.json index 4798aa66b2f..ab72d9f0538 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "lefthook": "^2.0.4", "msw": "^2.12.3", "phaser3spectorjs": "^0.0.8", + "type-fest": "^5.3.0", "typedoc": "^0.28.14", "typedoc-github-theme": "^0.3.1", "typedoc-plugin-coverage": "^4.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1607bfce611..e8889db4816 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -90,6 +90,9 @@ importers: phaser3spectorjs: specifier: ^0.0.8 version: 0.0.8 + type-fest: + specifier: ^5.3.0 + version: 5.3.0 typedoc: specifier: ^0.28.14 version: 0.28.14(typescript@5.9.3) @@ -1779,8 +1782,8 @@ packages: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} - type-fest@5.2.0: - resolution: {integrity: sha512-xxCJm+Bckc6kQBknN7i9fnP/xobQRsRQxR01CztFkp/h++yfVxUUcmMgfR2HttJx/dpWjS9ubVuyspJv24Q9DA==} + type-fest@5.3.0: + resolution: {integrity: sha512-d9CwU93nN0IA1QL+GSNDdwLAu1Ew5ZjTwupvedwg3WdfoH6pIDvYQ2hV0Uc2nKBLPq7NB5apCx57MLS5qlmO5g==} engines: {node: '>=20'} typedoc-github-theme@0.3.1: @@ -3288,7 +3291,7 @@ snapshots: statuses: 2.0.2 strict-event-emitter: 0.5.1 tough-cookie: 6.0.0 - type-fest: 5.2.0 + type-fest: 5.3.0 until-async: 3.0.2 yargs: 17.7.2 optionalDependencies: @@ -3561,7 +3564,7 @@ snapshots: minimist: 1.2.8 strip-bom: 3.0.0 - type-fest@5.2.0: + type-fest@5.3.0: dependencies: tagged-tag: 1.0.0 diff --git a/src/utils/anim-utils.ts b/src/utils/anim-utils.ts index f1a06552d38..d87ab887607 100644 --- a/src/utils/anim-utils.ts +++ b/src/utils/anim-utils.ts @@ -1,22 +1,19 @@ import { globalScene } from "#app/global-scene"; import type { SceneBase } from "#app/scene-base"; +import type { OmitIndexSignature, PickIndexSignature } from "type-fest"; + +type OmitWithoutIndex = PickIndexSignature & Omit, K>; + +interface PlayTweenConfig + extends OmitWithoutIndex {} /** - * Plays a Tween animation, resolving once the animation completes. + * Play a Tween animation and wait for its animation to complete. * @param config - The config for a single Tween - * @param scene - The {@linkcode SceneBase} on which the Tween plays; default {@linkcode globalScene} + * @param scene - (Default {@linkcode globalScene}) The {@linkcode SceneBase} on which the Tween plays * @returns A Promise that resolves once the Tween has been played. - * - * @privateRemarks - * The `config` input should not include an `onComplete` field as that callback is - * used to resolve the Promise containing the Tween animation. - * However, `config`'s type cannot be changed to something like `Omit` - * due to how the type for `TweenBuilderConfig` is defined. */ -export async function playTween( - config: Phaser.Types.Tweens.TweenBuilderConfig, - scene: SceneBase = globalScene, -): Promise { +export async function playTween(config: PlayTweenConfig, scene: SceneBase = globalScene): Promise { await new Promise(resolve => scene.tweens.add({ ...config,