Skip to content

Syntax lookup: Add @warning #676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions misc_docs/syntax/decorator_expression_warning.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
id: "expression-warning-decorator"
keywords: ["warning", "decorator"]
name: "@warning"
summary: "This is the `@warning` decorator."
category: "decorators"
---

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.

### Examples

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

```res
// Disables warning 27 for the deepClone function
@warning("-27")
let deepClone = (obj: 'a): 'a => %raw(`
JSON.parse(JSON.stringify(obj))
`);
```

```js
function deepClone(obj) {
return (JSON.parse(JSON.stringify(obj)));
}
```

</CodeTab>

### References

* [Warning Numbers](/docs/manual/latest/warning-numbers)
4 changes: 2 additions & 2 deletions pages/docs/manual/latest/warning-numbers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ description: "Available compiler warning numbers in ReScript"
canonical: "/docs/manual/latest/warning-numbers"
---

import {make as WarningTable} from "src/components/WarningTable.mjs"
import { make as WarningTable } from "src/components/WarningTable.mjs";

# Warning Numbers

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

<WarningTable />