Improve the type for os.date
using overloads
#874
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improves the type of
os.date
based on its documentation https://create.roblox.com/docs/reference/engine/libraries/os#dateWe know that the DateTypeResult table is only returned when the format string is either "*t" or "!*t", and otherwise its just a formatted string. This changes the type to showcase this appropriately.
I put the more strict type first in the overload because the ordering makes a difference
Note: the API docs used in studio (https://github.com/MaximumADHD/Roblox-Client-Tracker/blob/roblox/api-docs/en-us.json) may need to be updated to reflect the overloaded type instead.
It may be possible to add a lint of this too to provide analysis similar to how
string.format
works with a FormatString error. Will leave that for a different PR though