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

Abierto Apto para principiantes
#255 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
typescript
Área
data

Línea de trabajo

Falta la exportación en el punto de entrada del paquete index.ts de ecs-persistence; Matching está definido en src/match/match.ts, así que añade export type { Matching } allí y comprueba que un consumidor pueda importarlo. La segunda parte pide que el error de un índice que nombra un componente no cubierto informe los nombres del componente y del índice; localiza dónde la opción match de spawn lanza el error «names a component the snapshot's trait doesn't cover». Se da por terminado cuando el tipo es importable y el mensaje de error nombra tanto el componente como el índice.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
12
Forks
8
Merge medio
11 h 36 min
PR fusionados (30 d)
21

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de adobe/data

Todos los issues de adobe/data

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.