@@ -73,13 +73,11 @@ type function is_primitive(input_tag: string)
7373 input_tag == "string"
7474end
7575
76- type function unions_and_intersections_flatten (
77- input : typeof (types .unionof ()) | typeof (types .intersectionof ())
78- )
76+ type function unions_and_intersections_flatten (input : type )
7977 local input_tag = input .tag
8078
8179 if input_tag == "union" or input_tag == "intersection" then
82- local components = input :components ()
80+ local components : { type } = input :components ()
8381
8482 for idx = # components , 1 , - 1 do
8583 local component = components [idx ]
@@ -88,7 +86,7 @@ type function unions_and_intersections_flatten(
8886
8987 local component = unions_and_intersections_flatten (component )
9088 if component .tag == input_tag then
91- local sub_components = component :components ()
89+ local sub_components : { type } = component :components ()
9290
9391 components [idx ] = sub_components [1 ]
9492 for idx = 2 , # sub_components do
@@ -220,7 +218,7 @@ type function stringify_table(
220218
221219 -- Sorts the table keys so its stringified representation
222220 -- to ensure stringification is deterministic.
223- local keys = {}
221+ local keys : { type } = {}
224222 for key in properties do table.insert (keys , key ) end
225223 table.sort (keys , function (a , b ) return tostring (a ) > tostring (b ) end )
226224
@@ -264,7 +262,7 @@ type function stringify_table(
264262end
265263
266264type function stringify_components (
267- components : { [ number ]: type },
265+ components : { type },
268266 concatenator : string
269267)
270268 for idx , component in components do
402400
403401type function hashset_insert (
404402 hashset : typeof (types .newtable ()),
405- non_hashsettable : { [ number ]: type },
403+ non_hashsettable : { type },
406404 input : type ,
407405 input_tag : string
408406)
416414
417415type function hashset_has_type (
418416 hashset : typeof (types .newtable ()),
419- non_hashsettable : { [ number ]: type },
417+ non_hashsettable : { type },
420418 input : type ,
421419 input_tag : string
422420)
@@ -432,7 +430,7 @@ type function hashset_has_type(
432430 end
433431end
434432
435- type function hashset_from_components (input : { [ number ]: type })
433+ type function hashset_from_components (input : { type })
436434 local hashset = types .newtable ()
437435
438436 local input_len = # input
455453
456454--> Components Helpers -----------------------------------------------------------------
457455type function components_filter (
458- input : { [ number ]: type },
456+ input : { type },
459457 as : "union" | "intersection" ,
460- as_builder : (components : { [ number ]: type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
458+ as_builder : (components : { type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
461459 callback : (component : type ) -> boolean
462460)
463461 local input_len = # input
@@ -485,9 +483,9 @@ type function components_filter(
485483end
486484
487485type function components_flatten (
488- input : { [ number ]: type },
486+ input : { type },
489487 as : "union" | "intersection" ,
490- as_builder : (components : { [ number ]: type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ()))
488+ as_builder : (components : { type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ()))
491489)
492490 for idx = # input , 1 , - 1 do
493491 local component = input [idx ]
@@ -513,7 +511,7 @@ type function components_flatten(
513511end
514512
515513type function components_map (
516- input : { [ number ]: type },
514+ input : { type },
517515 callback : (value : type , ...any ) -> any ,
518516 ... : any
519517)
@@ -524,11 +522,11 @@ type function components_map(
524522end
525523
526524type function components_clean (
527- input : { [ number ]: type },
525+ input : { type },
528526 as : "union" | "intersection" ,
529- as_builder : (components : { [ number ]: type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
527+ as_builder : (components : { type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
530528 hashset : typeof (types .newtable ()),
531- non_hashsettable : { [ number ]: type }
529+ non_hashsettable : { type }
532530)
533531 local input_len = # input
534532 for idx = input_len , 1 , - 1 do
@@ -573,15 +571,15 @@ type function components_clean(
573571end
574572
575573type function components_clean_unions_and_intersections (
576- input : { [ number ]: type },
574+ input : { type },
577575 hashset : typeof (types .newtable ()),
578- non_hashsettable : { [ number ]: type },
576+ non_hashsettable : { type },
579577
580578 input_tag : string ,
581579 input_tag_other : string ,
582580
583- input_builder : (components : { [ number ]: type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
584- input_builder_other : (components : { [ number ]: type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ()))
581+ input_builder : (components : { type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ())),
582+ input_builder_other : (components : { type }) -> (typeof (types .unionof ()) | typeof (types .intersectionof ()))
585583)
586584 local input_len = # input
587585 for idx = input_len , 1 , - 1 do
@@ -625,7 +623,7 @@ type function components_clean_unions_and_intersections(
625623end
626624
627625type function components_find (
628- input : { [ number ]: type },
626+ input : { type },
629627 as : "union" | "intersection" ,
630628 callback : (component : type , component_tag : string ) -> boolean
631629): boolean
@@ -642,7 +640,7 @@ type function components_find(
642640end
643641
644642type function components_find_type (
645- input : { [ number ]: type },
643+ input : { type },
646644 as : "union" | "intersection" ,
647645 tag_to_find : string
648646): boolean
651649----------------------------------------------------------------------------------------
652650
653651--> Union Helpers ----------------------------------------------------------------------
654- type function union_from_components (input : { [ number ]: type })
652+ type function union_from_components (input : { type })
655653 local input_len = # input
656654 return if input_len == 0 then nil elseif input_len == 1 then input [1 ] else types .unionof (table.unpack (input ))
657655end
666664----------------------------------------------------------------------------------------
667665
668666--> Intersection Helpers ---------------------------------------------------------------
669- type function intersection_from_components (input : { [ number ]: type })
667+ type function intersection_from_components (input : { type })
670668 local input_len = # input
671669 return if input_len == 0 then nil elseif input_len == 1 then input [1 ] else types .intersectionof (table.unpack (input ))
672670end
@@ -1774,14 +1772,14 @@ export type function FlattenTable(input: type)
17741772 local output : typeof (types .newtable ()), output_idx : number
17751773 local can_add_read_indexer , can_add_write_indexer
17761774
1777- local output_union_components : { [ number ]: type } = {}
1778- local output_non_table_intersection_components : { [ number ]: type } = {}
1775+ local output_union_components : { type } = {}
1776+ local output_non_table_intersection_components : { type } = {}
17791777
17801778 for idx , component in components do
17811779 local component_tag = component .tag
17821780
17831781 if component_tag == "union" then
1784- for _ , sub_component in Flatten (component ):components () do
1782+ for _ , sub_component : type in Flatten (component ):components () do
17851783 table.insert (
17861784 output_union_components ,
17871785 sub_component
@@ -1840,7 +1838,7 @@ export type function FlattenTable(input: type)
18401838 local component_tag = component .tag
18411839
18421840 if component_tag == "union" then
1843- for _ , sub_component in Flatten (component ):components () do
1841+ for _ , sub_component : type in Flatten (component ):components () do
18441842 table.insert (
18451843 output_union_components ,
18461844 sub_component
0 commit comments