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

未关闭 适合新手
#255 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
data

调研方向

ecs-persistence 的包入口 index.ts 缺少该导出;Matching 定义在 src/match/match.ts 中,因此请在那里添加 export type { Matching },并检查使用方能否导入它。第二部分要求,当索引指定了未被覆盖的组件时,错误信息需要报告组件名和索引名;请找到 spawn 的 match 选项在哪里抛出“names a component the snapshot's trait doesn't cover”错误。当该类型可以被导入,且错误信息同时包含组件名和索引名时,即视为完成。

由索引模型根据 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 小时 2 分钟
30 天内合并 PR
23

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

adobe/data 的其他 Issue

查看 adobe/data 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。