Skip to content

Latest commit

 

History

History
 
 

scripts

Roblox API Types Generation

The globalTypes.d.luau file provides an autogenerated types definition file. This file is generated by dumpRobloxTypes.py:

$ python dumpRobloxTypes.py > globalTypes.d.luau

The script extracts type information from the Roblox API Dump:

We make use of some corrections provided by Roblox LSP:

DataTypes are also provided by Roblox LSP:

BrickColor information is retrieved from:

Contributing

There are often times when the information provided in the following dump information is either incorrect or too generic to provide useful intellisense. Pull requests to fix these definitions are welcome.

Inside dumpRobloxTypes.py, there are two collections that are of interest when submitting corrections:

  • IGNORED_MEMBERS: a dictionary of class name to a list of members that are ignored from the dump information. Add a member here if you wish to improve it's type definition.

  • EXTRA_MEMBERS: a dictionary of class name to a list of strings in definitions syntax format that are added to classes. Add a member definition here if you wish to overwrite an autogenerated definition or add a missing definition.

If types are not present at all in the autogenerated information, you can hardcode its definition. Modify one of three strings to add your type to the file:

  • START_BASE: types that go before anything else is defined
  • POST_DATATYPES_BASE: types that go after the Data Types have been defined
  • END_BASE: types that go after all autogenerated types have been defined

The relevant string to add it to depends on whether the type relies on other types. For simplicity, it is often best to add it to END_BASE. However, please do not add a hardcoded definition unless it is absolutely necessary.

In summary, to submit corrections, follow the following steps:

  1. Checkout the repository
  2. Edit IGNORED_MEMBERS and EXTRA_MEMBERS in dumpRobloxTypes.py with your fixes
  3. Run python dumpRobloxTypes.py > globalTypes.d.luau
  4. Commit and submit a Pull Request