The built-in type system currently supports the user in the following places:
- Getters and setters of components, e.g. the
setValuefunction of a Text Input component expects
string | nullas argument, and accessing
- All exposed properties of actions are typed (e.g.
number | undefined,
boolean | undefined, and so on) and the
- Other exposed objects like
inboxhave strictly typed properties and methods
You can find details about all types of exposed properties and functions in the component reference.
Violations are highlighted in our code editor in the same way such errors are displayed in your typical IDE:
Various type errors
In this example, there are multiple violations against the type system:
null, but the provided value is of type
state.setMyVariableexpects a single argument (the next value of the state variable
myVariable), but two arguments were provided
notify.successfunction expects two arguments (the message and a timeout in milliseconds), but only one argument was provided
Hovering over the place of error provides additional information about the error. Additionally, hovering over properties or functions reveal their particular type definition:
Type information on hover
The current type system is only the beginning of what we envision for the future of type support in Uify. The following features could drastically improve the coverage and usefulness of the type system:
- Ability to declare types of state variables, to have explicit typing of setters and getters of such variables.
- Automatic type inference of action results. For example, the fields of database query result sets could be automatically inferred to provide a better typing of the action
dataproperty than just
- Ability to declare accepted types of action
args, to highlight invocations of the
triggerfunction with incomplete or wrong arguments, and to use
argsinside of an action in a typed manner
- Full TypeScript support in all code editors
We are going to add such features step by step, and hope that it leads to a better developer experience and more reliable software being built with Uify.