Skip to content

Commit f8e82b9

Browse files
authored
Merge pull request #349 from kevanstannard/syntax-lookup-deprecated
Syntax lookup: Deprecated decorator
2 parents ed12796 + 0227742 commit f8e82b9

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
id: "expression-deprecated-decorator"
3+
keywords: ["deprecated", "decorator"]
4+
name: "@deprecated"
5+
summary: "This is the `@deprecated` decorator."
6+
category: "decorators"
7+
---
8+
9+
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.
10+
11+
Alternatively, use the `@@deprecated` decorator to add a deprecation warning to the file level.
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
id: "module-deprecated-decorator"
3+
keywords: ["deprecated", "decorator"]
4+
name: "@@deprecated"
5+
summary: "This is the `@@deprecated` decorator."
6+
category: "decorators"
7+
---
8+
9+
The `@@deprecated` decorator is used to add a deprecation note to the file-level of a module. The compiler and editor tooling will yield a warning whenever a deprecated file module is being used.
10+
11+
For more fine-grained control, use the `@deprecated` decorator to add deprecation warnings to specific types, values and submodules.
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>

0 commit comments

Comments
 (0)