API Module Structure
The bindings are organized by the Web API they represent. Each API has its interfaces and auxiliary types in a module named after the API, suffixed with API
to prevent collisions with the type module.
- package.json
Directorysrc
- DOMAPI.res
DirectoryDOMAPI
- HTMLElement.res
Within the API module, the structure is roughly as follows:
- Enum Types
- Interfaces
- Auxiliary Types
Enum types
Enum types are used to represent constants in the Web API. They are typically used as arguments to methods or properties. In ReScript terms these are variants:
Enums come first as they are always self-contained and do not depend on other types.
Interfaces
Interfaces are modeled as record types and are the core of the bindings. They represent the properties and methods of the Web API. If an interface inherits from another interface, the base interface is spread into the inheriting interface.
Auxiliary Types
Auxiliary types are used to represent types that are not directly related to the Web API but are used in the bindings. These can occur both before interfaces and after interfaces, depending on the context.