The philosophy surrounding type annotations is that you invest the time and effort of writing them in the hopes of them helping you catch silly coding mistakes in the future, thus saving you way more time and effort because you will be spending less time scratching your head on trivial problems. It will sound and feel tedious and redundant at first, but trust me, from experience, it is invaluable and extremely useful.
Type annotations is also integrated into the Roblox IntelliSense IDE so it can directly boost your productivity by suggesting the proper terms and stuff when you are coding; example:
You wouldn’t get that kind of suggestion without using type annotations! It even knows that because you gave the constructor a Part, that particular method will also return a Part.
But yeah please read the documentation, you definitely won’t understand everything at first because it’s literally like learning a new language. In fact, this is the code for the example above, see if you can understand it:
type class = {
new: <T, U>(driver: T, ...U) -> Car<T, U>,
}
export type Car<T, U> = {
driver: T,
passengers: {U},
GetDriver: (self: Car<T, U>) -> T,
GetPassenger: (self: Car<T, U>, seat: number) -> U?,
}
local Car = {}
Car.__index = Car
function Car.new<T, U>(driver: T, ...: U): Car<T, U>
local new = {
driver = driver,
passengers = {...},
}
return setmetatable(new, Car)::any
end
function Car.GetDriver<T, U>(self: Car<T, U>): T
return self.driver
end
function Car.GetPassenger<T, U>(self: Car<T, U>, seat: number): U?
return self.passengers[seat]
end
return (Car::any)::class