Skip to content

Document Subtyping / Structural Typing / Type Coercion Operator (:>) #150

Closed
@ryyppy

Description

@ryyppy

ReScript is internally using the object system within Js.t to allow structural typing.

e.g.

type user = { "name": string }

is expressed as Js.t < name : string >. This is kinda an implementation detail, but there are scenarios where you can use the :> operator to coerce between different object shapes explicitly.

e.g. x :> { . }

In ReScript lingo, we call Js.t<...> types Objects. Our current docs are covered in the Objects docs. Not sure if subtyping should be an advanced section here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions