Skip to content

Commit 54e7e92

Browse files
committed
Separate module and expression deprecated decorators
1 parent c86f3a0 commit 54e7e92

File tree

3 files changed

+77
-38
lines changed

3 files changed

+77
-38
lines changed

misc_docs/syntax/decorator_deprecated.mdx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
id: "scope-deprecated-decorator"
3+
keywords: ["deprecated", "decorator"]
4+
name: "@deprecated"
5+
summary: "This is the `expression deprecation` decorator."
6+
category: "decorators"
7+
---
8+
9+
The `@deprecated` decorator is used to annotate deprecated types, values and modules within a file. This may be used by ReScript tooling to highlight deprecated code during development.
10+
11+
See the `@@deprecated` decorator to deprecate whole file modules.
12+
13+
### Examples
14+
15+
<CodeTab labels={["ReScript", "JS Output"]}>
16+
17+
```res
18+
@deprecated
19+
type person = {id: int, name: string}
20+
21+
@deprecated
22+
let customDouble = n => n * 2
23+
24+
@deprecated("Use OtherModule.customTriple instead")
25+
let customTriple = n => n * 3
26+
27+
@deprecated("Use OtherModule instead")
28+
module MyModule = {
29+
type t
30+
}
31+
```
32+
33+
```js
34+
function customDouble(n) {
35+
return n << 1;
36+
}
37+
38+
function customTriple(n) {
39+
return Math.imul(n, 3);
40+
}
41+
42+
var MyModule = {};
43+
```
44+
45+
</CodeTab>
46+
47+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
id: "module-deprecated-decorator"
3+
keywords: ["deprecated", "decorator"]
4+
name: "@@deprecated"
5+
summary: "This is the `module deprecation` decorator."
6+
category: "decorators"
7+
---
8+
9+
The `@@deprecated` decorator is used to indicate that a whole module is deprecated. This may be used by ReScript tooling to highlight deprecated code during development.
10+
11+
See the `@deprecated` decorator to deprecate expressions.
12+
13+
### Examples
14+
15+
<CodeTab labels={["ReScript", "JS Output"]}>
16+
17+
```res
18+
// Indicate whole module is deprecated
19+
@@deprecated
20+
21+
// Indicate whole module is deprecated, with a comment
22+
@@deprecated("Use OtherModule instead")
23+
```
24+
25+
```js
26+
```
27+
28+
</CodeTab>
29+
30+

0 commit comments

Comments
 (0)