NateTheGreatt / bitECS

Functional, minimal, data-oriented, ultra-high performance ECS library written in JavaScript
Mozilla Public License 2.0
923 stars 84 forks source link

Missing `readonly` in ComponentType #124

Open dustinlacewell opened 1 year ago

dustinlacewell commented 1 year ago

In ComponentType I believe there is a missing readonly keyword when attempting to conditionally infer ListType:

  export type ComponentType<T extends ISchema> = {
    [key in keyof T]:
      T[key] extends Type
      ? ArrayByType[T[key]]
      : T[key] extends [infer RT, number]
        ? RT extends Type
          ? Array<ArrayByType[RT]>
          : unknown
        : T[key] extends ISchema
          ? ComponentType<T[key]>
          : unknown;
  };

Should read:

   export type ComponentType<T extends ISchema> = {
    [key in keyof T]:
      T[key] extends Type
      ? ArrayByType[T[key]]
      : T[key] extends readonly [infer RT, number]
        ? RT extends Type
          ? Array<ArrayByType[RT]>
          : unknown
        : T[key] extends ISchema
          ? ComponentType<T[key]>
          : unknown;
  };