@@ -36,7 +36,7 @@ type function assert_is(input: type, label: string, input_tag: string, ...: stri
3636 if select ("#" , ... ) == 1 then
3737 local is = ...
3838 if input_type ~= is then
39- assert_is_msg (input , input_type , label , `'{is }'` )
39+ error ( assert_is_msg (input , input_type , label , `'{is }'` ) )
4040 end
4141
4242 else
@@ -693,6 +693,25 @@ type function table_value_swap_remove(input: { [any]: any }, input_len: number,
693693 return input_len - 1
694694end
695695
696+ -- Sets the value of a table in a way which works around the
697+ -- erroneously seperated read and write fields in type hints issue.
698+ type function table_set_property (
699+ input : type ,
700+ key : type ,
701+ value : { read : type ? , write : type ? }?
702+ )
703+ if value == nil then return end
704+
705+ local value_read , value_write = value .read , value .write
706+ if value_read == value_write then
707+ input :setproperty (key , value_read )
708+
709+ else
710+ input :setreadproperty (key , value_read )
711+ input :setwriteproperty (key , value_write )
712+ end
713+ end
714+
696715type function table_value_is_empty (properties : { [any ]: any }, indexer : type )
697716 if indexer then return false end
698717
@@ -796,14 +815,7 @@ type function table_remove_indexer_hacky_fix(input: typeof(types.newtable()))
796815 local output = types .newtable ()
797816
798817 for key , value in input :properties () do
799- local value_read , value_write = value .read , value .write
800- if value_read == value_write then
801- output :setproperty (key , value_read )
802-
803- else
804- output :setreadproperty (key , value_read )
805- output :setwriteproperty (key , value_write )
806- end
818+ table_set_property (output , key , value )
807819 end
808820
809821 return output
@@ -817,14 +829,7 @@ type function table_remove_read_indexer_hacky_fix(input: typeof(types.newtable()
817829 local output = types .newtable ()
818830
819831 for key , value in input :properties () do
820- local value_read , value_write = value .read , value .write
821- if value_read == value_write then
822- output :setproperty (key , value_read )
823-
824- else
825- output :setreadproperty (key , value_read )
826- output :setwriteproperty (key , value_write )
827- end
832+ table_set_property (output , key , value )
828833 end
829834
830835 local indexer = input :indexer ()
@@ -846,14 +851,7 @@ type function table_remove_write_indexer_hacky_fix(input: typeof(types.newtable(
846851 local output = types .newtable ()
847852
848853 for key , value in input :properties () do
849- local value_read , value_write = value .read , value .write
850- if value_read == value_write then
851- output :setproperty (key , value_read )
852-
853- else
854- output :setreadproperty (key , value_read )
855- output :setwriteproperty (key , value_write )
856- end
854+ table_set_property (output , key , value )
857855 end
858856
859857 local indexer = input :indexer ()
0 commit comments