|
| 1 | +let decorators = |
| 2 | + [ |
| 3 | + ( "as", |
| 4 | + [ |
| 5 | + {|The `@as` decorator is commonly used on record types to alias record field names to a different JavaScript attribute name. |
| 6 | + |
| 7 | +This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords). |
| 8 | + |
| 9 | +It is also possible to map a ReScript record to a JavaScript array by passing indices to the `@as` decorator. |
| 10 | + |
| 11 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#as-decorator).|}; |
| 12 | + ] ); |
| 13 | + ( "dead", |
| 14 | + [ |
| 15 | + {|The `@dead` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. |
| 16 | + |
| 17 | +`@dead` suppresses reporting on the value/type, but can also be used to force the analysis to consider a value as dead. Typically used to acknowledge cases of dead code you are not planning to address right now, but can be searched easily later. |
| 18 | + |
| 19 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#dead-decorator). |
| 20 | + |
| 21 | +> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; |
| 22 | + ] ); |
| 23 | + ( "deriving", |
| 24 | + [ |
| 25 | + {|When the `@deriving` decorator is applied to a record type, it expands the type into a factory function plus a set of getter/setter functions for its fields. |
| 26 | + |
| 27 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#deriving-decorator).|}; |
| 28 | + ] ); |
| 29 | + ( "deprecated", |
| 30 | + [ |
| 31 | + {|The `@deprecated` decorator is used to add deprecation notes to types, values and submodules. The compiler and editor tooling will yield a warning whenever a deprecated entity is being used. |
| 32 | + |
| 33 | +Alternatively, use the `@@deprecated` decorator to add a deprecation warning to the file level. |
| 34 | + |
| 35 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#expression-deprecated-decorator).|}; |
| 36 | + ] ); |
| 37 | + ( "doesNotRaise", |
| 38 | + [ |
| 39 | + {|The `@doesNotRaise` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. |
| 40 | + |
| 41 | +`@doesNotRaise` is uses to override the analysis and state that an expression does not raise any exceptions, |
| 42 | +even though the analysis reports otherwise. This can happen for example in the case of array access where |
| 43 | +the analysis does not perform range checks but takes a conservative stance that any access |
| 44 | +could potentially raise. |
| 45 | +[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). |
| 46 | +> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; |
| 47 | + ] ); |
| 48 | + ( "genType", |
| 49 | + [ |
| 50 | + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. |
| 51 | + |
| 52 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#gentype-decorator).|}; |
| 53 | + ] ); |
| 54 | + ( "genType.as", |
| 55 | + [ |
| 56 | + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. |
| 57 | + |
| 58 | +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; |
| 59 | + ] ); |
| 60 | + ( "genType.import", |
| 61 | + [ |
| 62 | + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. |
| 63 | + |
| 64 | +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; |
| 65 | + ] ); |
| 66 | + ( "genType.opaque", |
| 67 | + [ |
| 68 | + {|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems. |
| 69 | + |
| 70 | +[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|}; |
| 71 | + ] ); |
| 72 | + ( "get", |
| 73 | + [ |
| 74 | + {|The `@get` decorator is used to bind to a property of an object. |
| 75 | + |
| 76 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-decorator).|}; |
| 77 | + ] ); |
| 78 | + ( "get_index", |
| 79 | + [ |
| 80 | + {|The `@get_index` decorator is used to access a dynamic property on an object, or an index of an array. |
| 81 | + |
| 82 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-index-decorator).|}; |
| 83 | + ] ); |
| 84 | + ( "inline", |
| 85 | + [ |
| 86 | + {|The `@inline` decorator tells the compiler to inline its value in every place the binding is being used, rather than use a variable. |
| 87 | + |
| 88 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#inline-decorator).|}; |
| 89 | + ] ); |
| 90 | + ( "int", |
| 91 | + [ |
| 92 | + {|The `@int` decorator can be used with polymorphic variants and the @as decorator on externals to modify the compiled JavaScript to use integers for the values instead of strings. |
| 93 | + |
| 94 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#int-decorator).|}; |
| 95 | + ] ); |
| 96 | + ( "live", |
| 97 | + [ |
| 98 | + {|The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis. |
| 99 | + |
| 100 | +`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on. |
| 101 | + |
| 102 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator). |
| 103 | + |
| 104 | +Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; |
| 105 | + ] ); |
| 106 | + ( "meth", |
| 107 | + [ |
| 108 | + {|The `@meth` decorator is used to call a function on a JavaScript object, and avoid issues with currying. |
| 109 | + |
| 110 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#meth-decorator).|}; |
| 111 | + ] ); |
| 112 | + ( "module", |
| 113 | + [ |
| 114 | + {|The `@module` decorator is used to bind to a JavaScript module. |
| 115 | + |
| 116 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-decorator).|}; |
| 117 | + ] ); |
| 118 | + ( "new", |
| 119 | + [ |
| 120 | + {| |
| 121 | +The `@new` decorator is used whenever you need to bind to a JavaScript class constructor that requires the new keword for instantiation.| |
| 122 | + |
| 123 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#new-decorator).|}; |
| 124 | + ] ); |
| 125 | + ( "obj", |
| 126 | + [ |
| 127 | + {|The `@obj` decorator is used to create functions that return JavaScript objects with properties that match the function's parameter labels. |
| 128 | + |
| 129 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#obj-decorator).|}; |
| 130 | + ] ); |
| 131 | + ( "raises", |
| 132 | + [ |
| 133 | + {|The `@raises` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis. |
| 134 | + |
| 135 | +`@raises` acknowledges that a function can raise exceptions that are not caught, and suppresses |
| 136 | +a warning in that case. Callers of the functions are then subjected to the same rule. |
| 137 | +Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions. |
| 138 | +[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md). |
| 139 | +> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|}; |
| 140 | + ] ); |
| 141 | + ( "react.component", |
| 142 | + [ |
| 143 | + {|The `@react.component` decorator is used to annotate functions that are RescriptReact components. |
| 144 | + |
| 145 | +You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions. |
| 146 | + |
| 147 | +Note: The `@react.component` decorator requires the react-jsx config to be set in your `bsconfig.json` to enable the required React transformations. |
| 148 | + |
| 149 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator).|}; |
| 150 | + ] ); |
| 151 | + ( "return", |
| 152 | + [ |
| 153 | + {|The `@return` decorator is used to control how `null` and `undefined` values are converted to option types in ReScript. |
| 154 | + |
| 155 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#return-decorator).|}; |
| 156 | + ] ); |
| 157 | + ( "scope", |
| 158 | + [ |
| 159 | + {|The `@scope` decorator is used with other decorators such as `@val` and `@module` to declare a parent scope for the binding. |
| 160 | + |
| 161 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#scope-decorator).|}; |
| 162 | + ] ); |
| 163 | + ( "send", |
| 164 | + [ |
| 165 | + {|The `@send` decorator is used to bind to a method on an object or array. |
| 166 | + |
| 167 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#send-decorator).|}; |
| 168 | + ] ); |
| 169 | + ( "set", |
| 170 | + [ |
| 171 | + {|The `@set` decorator is used to set a property of an object. |
| 172 | + |
| 173 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-decorator).|}; |
| 174 | + ] ); |
| 175 | + ( "set_index", |
| 176 | + [ |
| 177 | + {|The `@set_index` decorator is used to set a dynamic property on an object, or an index of an array. |
| 178 | + |
| 179 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-index-decorator).|}; |
| 180 | + ] ); |
| 181 | + ( "string", |
| 182 | + [ |
| 183 | + {|The `@string` decorator can be used with polymorphic variants and the `@as` decorator on externals to modify the string values used for the variants in the compiled JavaScript. |
| 184 | + |
| 185 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#string-decorator).|}; |
| 186 | + ] ); |
| 187 | + ( "this", |
| 188 | + [ |
| 189 | + {|The `@this` decorator may be used to bind to an external callback function that require access to a this context. |
| 190 | + |
| 191 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#this-decorator).|}; |
| 192 | + ] ); |
| 193 | + ( "unboxed", |
| 194 | + [ |
| 195 | + {|The `@unboxed` decorator provides a way to unwrap variant constructors that have a single argument, or record objects that have a single field. |
| 196 | + |
| 197 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unboxed-decorator).|}; |
| 198 | + ] ); |
| 199 | + ( "uncurry", |
| 200 | + [ |
| 201 | + {|The `@uncurry` decorator can be used to mark any callback argument within an external function as an uncurried function without the need for any explicit uncurried function syntax (`(.) => { ... }`). |
| 202 | + |
| 203 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#uncurry-decorator).|}; |
| 204 | + ] ); |
| 205 | + ( "unwrap", |
| 206 | + [ |
| 207 | + {|The `@unwrap` decorator may be used when binding to external functions that accept multiple types for an argument. |
| 208 | + |
| 209 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unwrap-decorator).|}; |
| 210 | + ] ); |
| 211 | + ( "val", |
| 212 | + [ |
| 213 | + {|The `@val` decorator allows you to bind to JavaScript values that are on the global scope. |
| 214 | + |
| 215 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#val-decorator).|}; |
| 216 | + ] ); |
| 217 | + ( "variadic", |
| 218 | + [ |
| 219 | + {|The `@variadic` decorator is used to model JavaScript functions that take a variable number of arguments, where all arguments are of the same type. |
| 220 | + |
| 221 | +[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#variadic-decorator).|}; |
| 222 | + ] ); |
| 223 | + ] |
0 commit comments