Type

Used to represent the type of a keyed object or a function.

Keyed Object Type

An object with keys can be represented as a type.

type SomeObject = {
  name: string;
  age: number;
  loggedIn: boolean;
};

Function Type

type ObjectTransformer = (value: string) -> string;

Positional arguments only

Types declared this way cannot be called with the parameter explosion modifier (#).

type Adder = (number, number) -> number;

State Types

Object types that can include getters and mutators.

type Counter = {
  value: number;

  get isGreater(otherValue: number): boolean;

  mut increment();
};

View Types

Use the result of a view composition to specify a type, these are computed at compile time.

Property interface

Describe the props that must be passed to the component on rendering.

Duck-typed state dependency interface

Must be provided with the mutators / getters / values in the specified type.

Typed state dependency interface with alias

For use with components that specify aliases for their providers.

Extend an existing view type

Declaring state provider types

Declaring partially applied dependencies and providers

View Composition Types

Views that allow parameters to be passed as the child of the JSX tag. By default the child type is any.

Mapped View Composition Types

Last updated

Was this helpful?