@colyseus/schema 3.0.63 → 3.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -499,23 +499,25 @@ export function defineTypes(
499
499
  // Helper type to extract InitProps from initialize method
500
500
  // Supports both single object parameter and multiple parameters
501
501
  // If no initialize method is specified, use AssignableProps for field initialization
502
- type ExtractInitProps<T> = T extends { initialize: (props: infer P) => void }
503
- ? P extends object
504
- ? P
505
- : never
506
- : T extends { initialize: (...args: infer P) => void }
507
- ? P extends readonly []
508
- ? never
502
+ type ExtractInitProps<T> = T extends { initialize: (...args: infer P) => void }
503
+ ? P extends readonly []
504
+ ? never
505
+ : P extends readonly [infer First]
506
+ ? First extends object
507
+ ? First
508
+ : P
509
509
  : P
510
- : T extends Definition
511
- ? AssignableProps<InferSchemaInstanceType<T>>
512
- : never;
510
+ : T extends Definition
511
+ ? AssignableProps<InferSchemaInstanceType<T>>
512
+ : never;
513
513
 
514
514
  // Helper type to determine if InitProps should be required
515
515
  type IsInitPropsRequired<T> = T extends { initialize: (props: any) => void }
516
516
  ? true
517
- : T extends { initialize: (...args: any[]) => void }
518
- ? true
517
+ : T extends { initialize: (...args: infer P) => void }
518
+ ? P extends readonly []
519
+ ? false
520
+ : true
519
521
  : false;
520
522
 
521
523
  export interface SchemaWithExtends<T extends Definition, P extends typeof Schema, > {
@@ -237,6 +237,7 @@ export class ChangeTree<T extends Ref = any> {
237
237
  if (typeof ((this.ref as any)[$childType]) !== "string") {
238
238
  // MapSchema / ArraySchema, etc.
239
239
  for (const [key, value] of (this.ref as MapSchema).entries()) {
240
+ if (!value) { continue; } // sparse arrays can have undefined values
240
241
  callback(value[$changes], this.indexes?.[key] ?? key);
241
242
  };
242
243
  }