Skip to content

Commit 632cfa8

Browse files
Syntax lookup: Add @warning (#676)
1 parent 1e8ff10 commit 632cfa8

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
id: "expression-warning-decorator"
3+
keywords: ["warning", "decorator"]
4+
name: "@warning"
5+
summary: "This is the `@warning` decorator."
6+
category: "decorators"
7+
---
8+
9+
The `@warning` decorator is used to modify the enabled compiler warnings for types, values and submodules. See [here](/docs/manual/latest/warning-numbers) for all available warning numbers.
10+
11+
### Examples
12+
13+
<CodeTab labels={["ReScript", "JS Output"]}>
14+
15+
```res
16+
// Disables warning 27 for the deepClone function
17+
@warning("-27")
18+
let deepClone = (obj: 'a): 'a => %raw(`
19+
JSON.parse(JSON.stringify(obj))
20+
`);
21+
```
22+
23+
```js
24+
function deepClone(obj) {
25+
return (JSON.parse(JSON.stringify(obj)));
26+
}
27+
```
28+
29+
</CodeTab>
30+
31+
### References
32+
33+
* [Warning Numbers](/docs/manual/latest/warning-numbers)

pages/docs/manual/latest/warning-numbers.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ description: "Available compiler warning numbers in ReScript"
44
canonical: "/docs/manual/latest/warning-numbers"
55
---
66

7-
import {make as WarningTable} from "src/components/WarningTable.mjs"
7+
import { make as WarningTable } from "src/components/WarningTable.mjs";
88

99
# Warning Numbers
1010

1111
You can configure which warnings the ReScript compiler generates
1212
[in the build configuration](/docs/manual/latest/build-configuration#warnings) or
13-
[using the `@@warning()` decorator](/syntax-lookup#module-warning-decorator).
13+
using the [`@warning()`](/syntax-lookup#expression-warning-decorator) or the [`@@warning()`](/syntax-lookup#module-warning-decorator) decorator.
1414

1515
<WarningTable />

0 commit comments

Comments
 (0)