Syntax Lookup

Enter some language construct you want to know more about.

@deriving

This is the @deriving decorator.

Use @deriving(accessors) on a record type to generate functions that read its fields.

The old @deriving(abstract) form was removed in v13. Use ordinary records and record literals for JavaScript objects, including optional fields and mutable fields when needed.

Example

ReScriptJS Output
@deriving(accessors)
type person = {
  name: string,
  age: int,
  job: string,
}

let joe = {name: "Joe", age: 20, job: "teacher"}

let joeName = name(joe)
let joeAge = age(joe)
let joeJob = job(joe)

References