Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 489 Bytes

bs.as.md

File metadata and controls

24 lines (18 loc) · 489 Bytes

[@bs.as]

bs.as can be used with bs.deriving abstract to rename fields. This is useful when field names are valid in JS, but not in BS.

For example:

[@bs.deriving abstract]
type button = {
  [@bs.as "type"] type_: string,
  [@bs.as "aria-label"] ariaLabel: string
};

let submitButton = button(~type_="submit", ~ariaLabel="Submit");

compiles to:

var submitButton = {
  type: "submit",
  "aria-label": "Submit"
};