Skip to main content

What are the utility types?

The utility types are TypeScript aliases that the other API modules use in their signatures. They exist only at the type level, so none of them is a value you can call at runtime. They describe function shapes, predicate results, color strings, and open-ended string unions. @unbound-app/api declares them, using the definitions from @unbound-app/types.
The @unbound-app/api package does not export a ./utils subpath, and the top-level entry does not re-export these types. You can’t import them by name from a plugin today. You’ll only meet them when you hover over an API function that uses them, or in a type error from one.

Type reference

Where you’ll see them

storage.get returns Widen<T>, where T is the type of the default you pass. The default false would otherwise infer as the literal type false, so the result is widened to boolean to allow for the stored value.
MetroFilter and the predicates accepted by storage return PredicateResult. A filter doesn’t have to return a strict boolean. Returning the property you’re checking for is enough.
Component props for Discord’s open-ended enums, such as variant, border, and shadow, use LiteralUnion. Your editor suggests the known values ('primary', 'secondary', and so on), and a value Discord adds in a later build still type-checks. The native module types loosely modeled native methods as Fn and PromiseFn when their exact arguments aren’t known.
Runtime helpers such as lazy, debounce, and uuid are internal to the Unbound client and are not exposed to plugins.To defer a module lookup, pass { lazy: true } to a Metro search: the search runs the first time you access the result. To wait for a module that hasn’t loaded yet, use metro.findLazy(filter), which returns the module if it’s already present or a promise that resolves once it loads.