Open
Description
Present a compact cheat sheet for decorators relevant for code generation. Here's a list of all decorators. Irrelevant ones to be removed:
@@deprecated@@warning- @as only used for runtime representation, except for default arguments
@as("someString") _
@bs.send.pipe@dead@deprecated@derivingAbout runtime representation@doesNotRaise@genType- @get
- @get_index
- @ignore
@inline@intnot relevant: about runtime representation@LiVe@methAbout runtime representation- @module
- @new
- @obj
@raises@react.component- @return This mixes runtime representation and externals: a post-processing for results
- @scope
- @send
- @set
- @set_index
@stringnot relevant: about runtime representation- @this Requires annotations on both external and uses
@unboxedAbout runtime representation- @uncurry This guarantees that the curried function is treated as if it were uncurried
- @unwrap Unwraps one level of unary polymorphci variants (e.g.
[#Int(int) | #Str(string)]
). Should probably be a language-level featureeither<(int, string)>
. - @Val
- [?] @variadic Should this be a language-level feature?
A few examples covered:
// @val
// external setTimeout: (unit => unit, int) => timeoutID = "setTimeout"
external setTimeout: (unit => unit, int) => timeoutID = "setTimeout($1, $2)"
// @get external getName: window => string = "name"
external getName: window => string = "$1.name"
// @set external setName: (window, string) => unit = "name"
external setName: (window, string) => unit = "$1.name = $2"
// @get_index external get: (t, string) => int = ""
external get: (t, string) => int = "$1[$2]"
// @set_index external set: (t, string, int) => unit = ""
external set: (t, string, int) => unit = "$1[$2] = $3"
// @module("path")
// external dirname: string => string = "dirname"
external dirname: string => string = "import(path).dirname($1)"
// @new external create: unit => t = "Date"
external create: unit => t = "new Date()"
// @send external getElementById: (document, string) => Dom.element = "getElementById"
external getElementById: (document, string) => Dom.element = "$1.getElementById($2)"
// @module("library-x")
// @val external doStuff: (@as(json`{format:"utf8", includeStuff: false}`) _, string) => string = "doStuff"
external doStuff: string => string = "import(library-x).doStuff({format: 'utf8', includeStuff: false}, $1)"
// @val external doSomething: (@ignore 'a, 'a) => unit = "doSomething"
external doSomething: ('a, 'a) => unit = "doSomething($2)"
// @obj
// external action: (~name: string, unit) => _ = ""
external action: (~name: string, unit) => _ = "{name:$1}"
// @scope("Math") @val
// external floor: float => int = "floor"
external floor: float => int = "Math.floor($1)"
Metadata
Metadata
Assignees
Labels
No labels