NateTheGreatt/bitECS

Missing `readonly` in ComponentType

dustinlacewell opened this issue · 0 comments

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;
};