#trying to make my script work with --!strict

12 messages · Page 1 of 1 (latest)

spice wolf
#

i had a few other issues but i fixed all the others,
this one however idk how to fix

there's no reason this warning should be appearing right? although the :GetRI function does return number? i check if it's nil which should convert the type to number right? or do i need to do something special to tell roblox that

#

i'm guessing i need to do some kind of type casting like in c like languages, idk how that works in LuaU though

vernal cloak
#

you could try
local aVal : number = self:GetRI(a)

#

@spice wolf

#

but idk if that would fix the error

spice wolf
#

but at that point it's a number? not a number so that would just cause more problems

#

i've tried redefining the variable to be as explicit as i can but it just won't work for some reason
even local aVal: number = aVal :: number won't work

#

i think it has something to do with the type that was inferred from self.Reg actually, i'll try to write a type for this entire metatable lol

#

okay i have figured out the problem, but not the solution

when self.Reg is first defined, its type is inferred as {[string]: number}
however this function upsets this and causes it to be {[string]: number?}

so i just need to figure out how to make it, not do that, or i can just give up and use --!nonstrict instead

vernal cloak
#

doesnt number? just mean that the type is not set and it just guesses what it could be?

spice wolf
#

it means that the type can be either number or nil

vernal cloak
#

oh