Browse Source

docs: Add `Option` in Javascript Anchor Types Reference (#3260)

acheron 1 year ago
parent
commit
28582a4515
1 changed files with 17 additions and 0 deletions
  1. 17 0
      docs/src/pages/docs/javascript-anchor-types.md

+ 17 - 0
docs/src/pages/docs/javascript-anchor-types.md

@@ -119,4 +119,21 @@ This reference shows you how Anchor maps Rust types to JavaScript/TypeScript typ
     .init([1, 2, 3])
     .init([1, 2, 3])
     .rpc();
     .rpc();
   ```
   ```
+
+---
+* `Option<T>`
+* `T | null | undefined`
+* ```javascript
+  // `null` for `None`
+  await program
+    .methods
+    .init(null)
+    .rpc();
+
+  // Non-nullish value for `Option<T>`
+  await program
+    .methods
+    .init(42)
+    .rpc();
+  ```
 {% /table %}
 {% /table %}