mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-12-16 14:55:22 +01:00
Merge pull request #6826 from Bertie690/play-tween-typing
[Dev] Update typing for `playTween` utility function
This commit is contained in:
parent
d8e8dbf8c2
commit
3302d23137
@ -54,6 +54,7 @@
|
|||||||
"lefthook": "^2.0.4",
|
"lefthook": "^2.0.4",
|
||||||
"msw": "^2.12.3",
|
"msw": "^2.12.3",
|
||||||
"phaser3spectorjs": "^0.0.8",
|
"phaser3spectorjs": "^0.0.8",
|
||||||
|
"type-fest": "^5.3.0",
|
||||||
"typedoc": "^0.28.14",
|
"typedoc": "^0.28.14",
|
||||||
"typedoc-github-theme": "^0.3.1",
|
"typedoc-github-theme": "^0.3.1",
|
||||||
"typedoc-plugin-coverage": "^4.0.2",
|
"typedoc-plugin-coverage": "^4.0.2",
|
||||||
|
|||||||
@ -90,6 +90,9 @@ importers:
|
|||||||
phaser3spectorjs:
|
phaser3spectorjs:
|
||||||
specifier: ^0.0.8
|
specifier: ^0.0.8
|
||||||
version: 0.0.8
|
version: 0.0.8
|
||||||
|
type-fest:
|
||||||
|
specifier: ^5.3.0
|
||||||
|
version: 5.3.0
|
||||||
typedoc:
|
typedoc:
|
||||||
specifier: ^0.28.14
|
specifier: ^0.28.14
|
||||||
version: 0.28.14(typescript@5.9.3)
|
version: 0.28.14(typescript@5.9.3)
|
||||||
@ -1779,8 +1782,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==}
|
resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
type-fest@5.2.0:
|
type-fest@5.3.0:
|
||||||
resolution: {integrity: sha512-xxCJm+Bckc6kQBknN7i9fnP/xobQRsRQxR01CztFkp/h++yfVxUUcmMgfR2HttJx/dpWjS9ubVuyspJv24Q9DA==}
|
resolution: {integrity: sha512-d9CwU93nN0IA1QL+GSNDdwLAu1Ew5ZjTwupvedwg3WdfoH6pIDvYQ2hV0Uc2nKBLPq7NB5apCx57MLS5qlmO5g==}
|
||||||
engines: {node: '>=20'}
|
engines: {node: '>=20'}
|
||||||
|
|
||||||
typedoc-github-theme@0.3.1:
|
typedoc-github-theme@0.3.1:
|
||||||
@ -3288,7 +3291,7 @@ snapshots:
|
|||||||
statuses: 2.0.2
|
statuses: 2.0.2
|
||||||
strict-event-emitter: 0.5.1
|
strict-event-emitter: 0.5.1
|
||||||
tough-cookie: 6.0.0
|
tough-cookie: 6.0.0
|
||||||
type-fest: 5.2.0
|
type-fest: 5.3.0
|
||||||
until-async: 3.0.2
|
until-async: 3.0.2
|
||||||
yargs: 17.7.2
|
yargs: 17.7.2
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@ -3561,7 +3564,7 @@ snapshots:
|
|||||||
minimist: 1.2.8
|
minimist: 1.2.8
|
||||||
strip-bom: 3.0.0
|
strip-bom: 3.0.0
|
||||||
|
|
||||||
type-fest@5.2.0:
|
type-fest@5.3.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
tagged-tag: 1.0.0
|
tagged-tag: 1.0.0
|
||||||
|
|
||||||
|
|||||||
@ -1,22 +1,19 @@
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import type { SceneBase } from "#app/scene-base";
|
import type { SceneBase } from "#app/scene-base";
|
||||||
|
import type { OmitIndexSignature, PickIndexSignature } from "type-fest";
|
||||||
|
|
||||||
|
type OmitWithoutIndex<O extends object, K extends keyof O> = PickIndexSignature<O> & Omit<OmitIndexSignature<O>, K>;
|
||||||
|
|
||||||
|
interface PlayTweenConfig
|
||||||
|
extends OmitWithoutIndex<Phaser.Types.Tweens.TweenBuilderConfig, "onComplete" | "onCompleteParams"> {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 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.
|
* @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<TweenBuilderConfig, "onComplete">`
|
|
||||||
* due to how the type for `TweenBuilderConfig` is defined.
|
|
||||||
*/
|
*/
|
||||||
export async function playTween(
|
export async function playTween(config: PlayTweenConfig, scene: SceneBase = globalScene): Promise<void> {
|
||||||
config: Phaser.Types.Tweens.TweenBuilderConfig,
|
|
||||||
scene: SceneBase = globalScene,
|
|
||||||
): Promise<void> {
|
|
||||||
await new Promise(resolve =>
|
await new Promise(resolve =>
|
||||||
scene.tweens.add({
|
scene.tweens.add({
|
||||||
...config,
|
...config,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user