ecs-persistence: export the Matching type of spawn's match option

オープン 初心者向け
#255 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
data

調査の方向性

ecs-persistence のパッケージエントリポイント index.ts にエクスポートがありません。Matching は src/match/match.ts で定義されているため、そこに export type { Matching } を追加し、利用側から import できることを確認してください。後半では、カバーされていないコンポーネントを指定したインデックスのエラーに、コンポーネント名とインデックス名を含めることを求めています。spawn の match オプションが「names a component the snapshot's trait doesn't cover」エラーを発生させている箇所を見つけてください。型が import でき、エラーメッセージにコンポーネントとインデックスの両方の名前が含まれていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Summary

@adobe/ecs-persistence's spawn takes match?: readonly Matching[], but Matching isn't exported from the package, so an application that forwards a match argument (a restore function that takes the indexes to match by) has to spell the type out as Index<{ readonly unique: true }>, which is what Matching is defined as in src/match/match.ts.

Where this came from (mecs)

loadTab(world, bytes, match?) and restoreTab(world, match?) pass the indexes through to spawn({ world, snapshot, match, update: true, entities: false }) (the #249 feature, which works well: the camera is made at startup and the saved place and look update it by name). I wanted the parameter typed readonly Matching[], imported from @adobe/ecs-persistence, so that the application's types follow the package's if its definition changes; it isn't exported, so I wrote readonly Index<{ readonly unique: true }>[] instead.

What I need

export type { Matching } from "./match/match.js" in ecs-persistence's index.ts.

A related gap in the same feature

match fails for an index whose key, with or not names a component the snapshot's trait doesn't cover. In mecs the natural index of a camera by name, Index.create({ key: [cameraName], unique: true, components: { with: CameraView } }), where CameraView includes View.target, View.projection and others that aren't part of the saved state, had to be reduced to with: [cameraName]. That is fine here (the failure is clear: "…names a component the snapshot's trait doesn't cover"), but the error could say which component and which index, since the usual fix is narrowing the index's with.

主要言語
TypeScript
スター
12
フォーク
8
平均マージ
11時間 36分
マージ済み PR(30日)
21

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

adobe/data のほかの issue

adobe/data の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。