Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 770 Bytes

decorator_as.mdx

File metadata and controls

36 lines (26 loc) · 770 Bytes
id keywords name summary category
as-decorator
as
decorator
@as
This is the `@as` decorator.
decorators

The @as decorator is commonly used on record types to alias record field names to a different JavaScript attribute name.

This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords).

Example

<CodeTab labels={["ReScript", "JS Output"]}>

type action = {
  @as("type") type_: string
}

let action = {type_: "ADD_USER"}
var action = {
  type: "ADD_USER"
};

References