I’m currently writing a simple module which takes in a list of time stamps and lerpable values to create a path.
I’d like for this module to handle not only Vector3s and CFrames, but also any other value that can be :Lerp()
ed now and in the future, without modifying the source code again.
To achieve this goal, I’ve created a value
type, which is defined as follows:
type value = {
Lerp: (value, value, number) -> value
}
I’d imagine that Vector3s and the like could easily be converted to this type, as the type value
does not contain any information that a Vector3 does not contain. This doesn’t appear to be the case though, as roblox issues the warning Type 'Vector3' could not be converted into 'value'
.
I’ve attempted to make the type value
an union between the definition above and any
, and also making it either of the two, but neither of these achieve what I want.
Making an union only makes the error message needlessly complicated without giving any new information, while making the type either any or the definition above will not give autocorrection at all.
The following piece of code has this issue isolated, and could make testing a bit faster if need be.
--!strict
type value = {
Lerp: (value, value, number) -> value
}
local a: Vector3 = Vector3.new(1,1,1)
local b: value = a -- This should have the warning