Add strong typing to `TweenBuilderConfig` callback types
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- api
調査の方向性
まず、TweenBuilderConfig の定義と、issue で参照されている Phaser.Types.Tweens の callback 型宣言を探します。target、callback の scope、callback のパラメーター、Function 型のオプションが現在どのように公開されているかを確認します。issue で説明されている安全でない any と Function の使用をなくし、設定で target と callback をより厳密に型付けできれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The current type of TweenBuilder looks like this:
type TweenBuilderConfig = {[key: string]: any} & {
/**
* The object, or an array of objects, to run the tween on.
*/
targets: any;
/**
* The number of milliseconds to delay before the tween will start.
*/
delay?: number | Function;
/**
* The duration of the tween in milliseconds.
*/
duration?: number;
/**
* The easing equation to use for the tween.
*/
ease?: string | Function;
/**
* Optional easing parameters.
*/
easeParams?: any[];
/**
* The number of milliseconds to hold the tween for before yoyo'ing.
*/
hold?: number;
/**
* The number of times each property tween repeats.
*/
repeat?: number;
/**
* The number of milliseconds to pause before a repeat.
*/
repeatDelay?: number;
/**
* Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete.
*/
yoyo?: boolean;
/**
* Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property.
*/
flipX?: boolean;
/**
* Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property.
*/
flipY?: boolean;
/**
* The time the tween will wait before the onComplete event is dispatched once it has completed, in ms.
*/
completeDelay?: string | number | Function | object | any[];
/**
* The number of times the tween will repeat. (A value of 1 means the tween will play twice, as it repeated once.) The first loop starts after every property in the tween has completed once.
*/
loop?: string | number | Function | object | any[];
/**
* The time the tween will pause before starting either a yoyo or returning to the start for a repeat.
*/
loopDelay?: string | number | Function | object | any[];
/**
* Does the tween start in a paused state (true) or playing (false)?
*/
paused?: boolean;
/**
* The properties to tween.
*/
props?: {[key: string]: (number|string|Phaser.Types.Tweens.GetEndCallback|Phaser.Types.Tweens.TweenPropConfig)};
/**
* The scope (or context) for all of the callbacks. The default scope is the tween.
*/
callbackScope?: any;
/**
* A function to call when the tween completes.
*/
onComplete?: Phaser.Types.Tweens.TweenOnCompleteCallback;
/**
* Additional parameters to pass to `onComplete`.
*/
onCompleteParams?: any[];
/**
* A function to call each time the tween loops.
*/
onLoop?: Phaser.Types.Tweens.TweenOnLoopCallback;
/**
* Additional parameters to pass to `onLoop`.
*/
onLoopParams?: any[];
/**
* A function to call each time a property tween repeats. Called once per property per target.
*/
onRepeat?: Phaser.Types.Tweens.TweenOnRepeatCallback;
/**
* Additional parameters to pass to `onRepeat`.
*/
onRepeatParams?: any[];
/**
* A function to call when the tween starts playback, after any delays have expired.
*/
onStart?: Phaser.Types.Tweens.TweenOnStartCallback;
/**
* Additional parameters to pass to `onStart`.
*/
onStartParams?: any[];
/**
* A function to call when the tween is stopped.
*/
onStop?: Phaser.Types.Tweens.TweenOnStopCallback;
/**
* Additional parameters to pass to `onStop`.
*/
onStopParams?: any[];
/**
* A function to call each time the tween steps. Called once per property per target.
*/
onUpdate?: Phaser.Types.Tweens.TweenOnUpdateCallback;
/**
* Additional parameters to pass to `onUpdate`.
*/
onUpdateParams?: any[];
/**
* A function to call each time a property tween yoyos. Called once per property per target.
*/
onYoyo?: Phaser.Types.Tweens.TweenOnYoyoCallback;
/**
* Additional parameters to pass to `onYoyo`.
*/
onYoyoParams?: any[];
/**
* A function to call when the tween becomes active within the Tween Manager.
*/
onActive?: Phaser.Types.Tweens.TweenOnActiveCallback;
/**
* Additional parameters to pass to `onActive`.
*/
onActiveParams?: any[];
/**
* A function to call when the tween is paused.
*/
onPause?: Phaser.Types.Tweens.TweenOnPauseCallback;
/**
* Additional parameters to pass to `onPause`.
*/
onPauseParams?: any[];
/**
* A function to call when the tween is resumed after being paused.
*/
onResume?: Phaser.Types.Tweens.TweenOnResumeCallback;
/**
* Additional parameters to pass to `onResume`.
*/
onResumeParams?: any[];
/**
* Will the Tween be automatically destroyed on completion, or retained for future playback?
*/
persist?: boolean;
/**
* The interpolation function to use if the `value` given is an array of numbers.
*/
interpolation?: string | Function;
};
This:
- uses a value of
anyfortarget, which is unsafe. - uses
any[]as the type for the "extra parameters" passed to various callbacks (and ananycallback scope), which is type-unsafe and has poor heuristics; nothing will stop you from forgetting to pass an extra parameter to a callback (and producingundefined), or expectingtargetto be a different type as is expected. - Numerous uses of
Functionwhich provides no information about callback types or return values
In an ideal world, this should be generic on targets and the various callback parameter types.
Unfortunately, TS doesn't really make it easy to parameterize callback types without introducing many many type parameters, so we might need several @template declarations to get the job done.
- 主要言語
- JavaScript
- スター
- 40.7k
- フォーク
- 7.2k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
phaserjs/phaser のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 3 日以内に返信
-
Type definition for TilemapLayer.getTileAt is wrong対応中かも @hkbughk が 34 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 3 日以内に返信
-
Shader.preDestroy leaks its ShaderQuad's vertex buffer and VAO on every create/destroy cycle (4.2.1)対応中かも @k1epg01ng129-eng が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 3 日以内に返信
-
Black opaque background on transparent Phaser.Text textures in Phaser 4.2.1 on older iOS WebGL対応中かも @SamuelMalmfors が 14 日前に担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
phaserjs/phaser#7392 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
phaserjs/phaser の issue をすべて見る
似ている issue
-
enhancement ready
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DCGM/semant-demo#708 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
agents area: runtime automation chore cli consistency dependencies developer-experience difficulty: easy documentation enhancement good first issue help wanted hygiene json-output priority: P3 starters tests
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Client codegen: an import repeated in an impl file is emitted twice, and the browser rejects the module対応中かも @MalithaPrabhashana が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
jaseci-labs/jac#10756 ·
メンテナーはふだん 1 日以内に返信