Type safety
A solid type system is an important driver of reliable and maintainable software systems. While coding in Uify is currently focused on JavaScript as primary programming language, there is a basic type system in place to avoid errors and guide the user towards correct usage of the exposed API.
The built-in type system currently supports the user in the following places:
- Getters and setters of components, e.g. the
setValue
function of a Text Input component expectsstring | null
as argument, and accessingvalue
returns astring
- All exposed properties of actions are typed (e.g.
executionTime
isnumber | undefined
,success
isboolean | undefined
, and so on) and thetrigger
function returnsPromise<unknown>
- Other exposed objects like
dateFns
,nanoid
,state
,notify
andinbox
have 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:
setValue
expects astring
ornull
, but the provided value is of typenumber
state.setMyVariable
expects a single argument (the next value of the state variablemyVariable
), but two arguments were provided- The
notify.success
function 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
data
property than justunknown
- Ability to declare accepted types of action
args
, to highlight invocations of thetrigger
function with incomplete or wrong arguments, and to useargs
inside 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.
Last modified 5mo ago