Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the type for os.date using overloads #874

Merged
merged 1 commit into from
May 1, 2023

Conversation

JohnnyMorganz
Copy link
Contributor

Improves the type of os.date based on its documentation https://create.roblox.com/docs/reference/engine/libraries/os#date

We 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.

image

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

@vegorov-rbx vegorov-rbx merged commit e8c0550 into luau-lang:master May 1, 2023
@JohnnyMorganz JohnnyMorganz deleted the os-date-overloads branch May 1, 2023 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants