@@ -293,68 +293,86 @@ const TypeMutations: Record<string, TypeMutation> = {
293
293
GArray : {
294
294
generic_parameters : {
295
295
T : {
296
- default : GodotAnyType ,
296
+ default : `${ GodotAnyType } | ${ GodotAnyType } []` ,
297
+ extends : `${ GodotAnyType } | ${ GodotAnyType } []`
297
298
} ,
298
299
} ,
299
300
intro : [
300
301
"/** Builder function that returns a GArray populated with elements from a JS array. */" ,
301
- "static create<T>(elements: [T] extends [GArray<infer E>] ? Array<E | GProxyValueWrap<E>> : Array<T | GProxyValueWrap<T>>):" ,
302
- " [T] extends [GArray<infer E>]" ,
303
- " ? [GValueWrap<E>] extends [never]" ,
304
- " ? never" ,
305
- " : GArray<GValueWrap<T>>" ,
306
- " : [GValueWrap<T>] extends [never]" ,
307
- " ? never" ,
308
- " : GArray<GValueWrap<T>>" ,
309
- "[Symbol.iterator](): IteratorObject<T>" ,
302
+ "static create<A extends any[]>(elements: A): GValueWrap<A>" ,
303
+ "static create<A extends GArray<any>>(" ,
304
+ " elements: A extends GArray<infer T>" ,
305
+ " ? [T] extends [any[]]" ,
306
+ " ? { [I in keyof T]: GDataStructureCreateValue<T[I]> }" ,
307
+ " : Array<GDataStructureCreateValue<T>>" ,
308
+ " : never" ,
309
+ "): GValueWrap<A>" ,
310
+ "static create<E extends GAny>(elements: Array<GDataStructureCreateValue<E>>): GArray<E>" ,
311
+ "[Symbol.iterator](): IteratorObject<GArrayElement<T>>" ,
310
312
"/** Returns a Proxy that targets this GArray but behaves similar to a JavaScript array. */" ,
311
- "proxy<Write extends boolean = false>(): Write extends true ? GArrayProxy<T> : GArrayReadProxy<T >" ,
313
+ "proxy<Write extends boolean = false>(): Write extends true ? GArrayProxy<GArrayElement<T>> : GArrayReadProxy<GArrayElement<T> >" ,
312
314
"" ,
313
- `${ names . get_member ( "set_indexed" ) } (index: number , value: T ): void` ,
314
- `${ names . get_member ( "get_indexed" ) } (index: number ): T ` ,
315
+ `${ names . get_member ( "set_indexed" ) } <I extends int64> (index: I , value: GArrayElement<T, I> ): void` ,
316
+ `${ names . get_member ( "get_indexed" ) } <I extends int64> (index: I ): GArrayElement<T, I> ` ,
315
317
] ,
316
318
property_overrides : {
317
- set : mutate_parameter_type ( "value" , "T" ) ,
318
- push_back : mutate_parameter_type ( "value" , "T " ) ,
319
- push_front : mutate_parameter_type ( "value" , "T " ) ,
320
- append : mutate_parameter_type ( "value" , "T " ) ,
321
- insert : mutate_parameter_type ( "value" , "T " ) ,
322
- fill : mutate_parameter_type ( "value" , "T " ) ,
323
- erase : mutate_parameter_type ( "value" , "T " ) ,
324
- count : mutate_parameter_type ( "value" , "T " ) ,
325
- has : mutate_parameter_type ( "value" , "T " ) ,
326
- bsearch : mutate_parameter_type ( "value" , "T " ) ,
327
- bsearch_custom : chain_mutators ( mutate_parameter_type ( "value" , "T " ) , mutate_parameter_type ( "func" , "Callable2<T, T, boolean>" ) ) ,
328
- find : mutate_parameter_type ( "what" , "T " ) ,
329
- rfind : mutate_parameter_type ( "what" , "T " ) ,
330
- get : mutate_return_type ( "T" ) ,
331
- front : mutate_return_type ( "T " ) ,
332
- back : mutate_return_type ( "T " ) ,
333
- pick_random : mutate_return_type ( "T " ) ,
334
- pop_back : mutate_return_type ( "T " ) ,
335
- pop_front : mutate_return_type ( "T " ) ,
336
- pop_at : mutate_return_type ( "T " ) ,
337
- min : mutate_return_type ( "T " ) ,
338
- max : mutate_return_type ( "T " ) ,
339
- sort_custom : mutate_parameter_type ( "func" , "Callable2<T, T, boolean>" ) ,
340
- all : mutate_parameter_type ( "method" , "Callable1<T, boolean>" ) ,
341
- any : mutate_parameter_type ( "method" , "Callable1<T, boolean>" ) ,
342
- filter : chain_mutators ( mutate_parameter_type ( "method" , "Callable1<T, boolean>" ) , mutate_return_type ( "GArray<T >" ) ) ,
343
- map : chain_mutators ( mutate_parameter_type ( "method" , "Callable1<T, U>" ) , mutate_return_type ( "GArray<U>" ) , mutate_template ( "U" ) ) ,
344
- append_array : mutate_parameter_type ( "array" , "GArray<T >" ) ,
345
- duplicate : mutate_return_type ( "GArray<T> " ) ,
346
- slice : mutate_return_type ( "GArray<T >" ) ,
319
+ set : [ `set<I extends int64>(index: I, value: GArrayElement<T, I>): void` ] ,
320
+ push_back : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
321
+ push_front : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
322
+ append : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
323
+ insert : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
324
+ fill : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
325
+ erase : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
326
+ count : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
327
+ has : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
328
+ bsearch : mutate_parameter_type ( "value" , "GArrayElement<T> " ) ,
329
+ bsearch_custom : chain_mutators ( mutate_parameter_type ( "value" , "GArrayElement<T> " ) , mutate_parameter_type ( "func" , "Callable<(a: GArrayElement<T>, b: GArrayElement<T>) => boolean>" ) ) ,
330
+ find : mutate_parameter_type ( "what" , "GArrayElement<T> " ) ,
331
+ rfind : mutate_parameter_type ( "what" , "GArrayElement<T> " ) ,
332
+ get : [ `get<I extends int64>(index: I): GArrayElement<T, I>` ] ,
333
+ front : mutate_return_type ( "GArrayElement<T> " ) ,
334
+ back : mutate_return_type ( "GArrayElement<T> " ) ,
335
+ pick_random : mutate_return_type ( "GArrayElement<T> " ) ,
336
+ pop_back : mutate_return_type ( "GArrayElement<T> " ) ,
337
+ pop_front : mutate_return_type ( "GArrayElement<T> " ) ,
338
+ pop_at : mutate_return_type ( "GArrayElement<T> " ) ,
339
+ min : mutate_return_type ( "GArrayElement<T> " ) ,
340
+ max : mutate_return_type ( "GArrayElement<T> " ) ,
341
+ sort_custom : mutate_parameter_type ( "func" , "Callable<(a: GArrayElement<T>, b: GArrayElement<T>) => boolean>" ) ,
342
+ all : mutate_parameter_type ( "method" , "Callable<(value: GArrayElement<T>) => boolean>" ) ,
343
+ any : mutate_parameter_type ( "method" , "Callable<(value: GArrayElement<T>) => boolean>" ) ,
344
+ filter : chain_mutators ( mutate_parameter_type ( "method" , "Callable<(value: GArrayElement<T>) => boolean>" ) , mutate_return_type ( "GArray<GArrayElement<T> >" ) ) ,
345
+ map : chain_mutators ( mutate_parameter_type ( "method" , "Callable<(value: GArrayElement<T>) => U>" ) , mutate_return_type ( "GArray<U>" ) , mutate_template ( "U" ) ) ,
346
+ append_array : mutate_parameter_type ( "array" , "GArray<GArrayElement<T> >" ) ,
347
+ duplicate : mutate_return_type ( "this " ) ,
348
+ slice : mutate_return_type ( "GArray<GArrayElement<T> >" ) ,
347
349
} ,
348
350
} ,
349
351
GDictionary : {
352
+ prelude : [
353
+ "type GArrayCreateSource<T> = ReadonlyArray<T> | {" ,
354
+ " [Symbol.iterator](): IteratorObject<GDataStructureCreateValue<T>>;" ,
355
+ " [K: number]: GDataStructureCreateValue<T>;" ,
356
+ "}" ,
357
+ "type GDataStructureCreateValue<V> = V | (" ,
358
+ " V extends GArray<infer T>" ,
359
+ " ? [T] extends [any[]]" ,
360
+ " ? GArrayCreateSource<{ [I in keyof T]: GDataStructureCreateValue<T[I]> }>" ,
361
+ " : GArrayCreateSource<GDataStructureCreateValue<T>>" ,
362
+ " : V extends GDictionary<infer T>" ,
363
+ " ? { [K in keyof T]: GDataStructureCreateValue<T[K]> }" ,
364
+ " : never" ,
365
+ " )"
366
+ ] ,
350
367
generic_parameters : {
351
368
T : {
352
369
default : "Record<any, any>" ,
353
370
} ,
354
371
} ,
355
372
intro : [
356
373
"/** Builder function that returns a GDictionary with properties populated from a source JS object. */" ,
357
- "static create<T>(properties: T extends GDictionary<infer S> ? GDictionaryProxy<S> : GDictionaryProxy<T>): T extends GDictionary<infer S> ? GValueWrap<S> : GValueWrap<T>" ,
374
+ "static create<V extends { [key: number | string]: GWrappableValue }>(properties: V): GValueWrap<V>" ,
375
+ "static create<V extends GDictionary<any>>(properties: V extends GDictionary<infer T> ? { [K in keyof T]: GDataStructureCreateValue<T[K]> } : never): V" ,
358
376
"[Symbol.iterator](): IteratorObject<{ key: any, value: any }>" ,
359
377
"/** Returns a Proxy that targets this GDictionary but behaves similar to a regular JavaScript object. Values are exposed as enumerable properties, so Object.keys(), Object.entries() etc. will work. */" ,
360
378
"proxy<Write extends boolean = false>(): Write extends true ? GDictionaryProxy<T> : GDictionaryReadProxy<T>" ,
0 commit comments