One extra note is that i aswell would like to fix another type thing, which is that it dosent autocomplete outside the module, and in the LerpService modules, the functions appear, but those functions should be for the lerp not the service.
It’s a type error meaing it doesn’t do anything. If you want to get rid of it you could set the luau type check mode to nonstrict in workspace properties
Asking questions about working with the type system is valid and shouldn’t be discouraged. The type system is useful and using it properly is extremely helpful.
I couldn’t get any such error trying to reproduce this myself with the new type solver—try enabling that beta and see if it helps.
It’s important to state that your type structure is in very poor style. Lerp is never defined to have any functions attached to it, which is why you don’t see completion helpers. LerpService should not be the metatable of Lerp. Lerp should really just have its own, private metatable.
The LerpService type shouldn’t exist. It’s bad style to explicitly give your module a type as you remove all of the automatic type information, and you shouldn’t be using it like a metatable.
I don’t see why you can’t just have it as its own thing.
local lerpMeta = {}
function lerpMeta:Play() end
export type Lerp = typeof(setmetatable({ --[[fields]] }, lerpMeta))
local LerpService = {}
function LerpService.create(): Lerp
local Lerp: Lerp = setmetatable({}, lerpMeta)
return Lerp
end
return LerpService
local LerpMeta = {}
export type Lerp = typeof(setmetatable({ }::{
Completed : any,
Stopped : any,
Deleted : any,
Object : BasePart,
Starting : CFrame,
DTime : number,
Loop : number,
Time : number,
Playing : boolean,
Reverse : boolean,
Id : number,
Alpha : number,
Value : CFrame,
Info : Type.LerpInfo,
Play : () -> ()
}
, LerpMeta))
Constructor:
function LerpService.create(Object: BasePart, Property: {[any]: CFrame}, LerpInfo: Type.LerpInfo): Lerp
local Name: any, Value: any = Utils.GetTableValues(Property)
local LerpObject = setmetatable({},LerpMeta)
LerpObject.Completed = GoodSignal.new()
LerpObject.Stopped = GoodSignal.new()
LerpObject.Deleted = GoodSignal.new()
LerpObject.Object = Object :: BasePart
LerpObject.Starting = Object.CFrame
LerpObject.DTime = 0
LerpObject.Loop = 0 :: number
LerpObject.Time = 0
LerpObject.Playing = false
LerpObject.Reverse = false
LerpObject.Id = #Lerps + 1
LerpObject.Alpha = 0
LerpObject.Value = Value :: any
LerpObject.Info = LerpInfo or LerpService.NewLerpInfo(1,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0) :: Type.LerpInfo
Utils.CreationWarnings(LerpObject:: {[any]: any}, LerpObject.Info:: Type.LerpInfo)
Debug.print("Lerp ("..LerpObject.Id..") created:",LerpObject)
return LerpObject :: Lerp
end
And i separated the meta tables and to test, added a function to the table, now, how would i do the autocomplete work?
This is my first time trying to use types.