Skip to content

Commit fbdc27c

Browse files
committed
fix(docs): correct JavaScript result type example in fundamentals
Update JavaScript usage example to match actual WIT definition: - Change from generic result<T, E> format to custom calculation-result record - Fix interface name from 'math' to 'calc' matching actual implementation - Show correct return format: { success: bool, error: option<string>, value: option<f64> } Verified against examples/js_component/wit/calculator.wit and src/calculator.js
1 parent cd9d6cc commit fbdc27c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs-site/src/content/docs/learn/fundamentals.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ impl Math for Component {
142142
**JavaScript Usage:**
143143
```javascript
144144
// Generated automatically from WIT
145-
import { math } from './calculator.js';
145+
import { calc } from './calculator.js';
146146

147-
const result = math.add(5.0, 3.0); // Returns: 8.0
148-
const divided = math.divide(10.0, 2.0); // Returns: { ok: 5.0 }
149-
const error = math.divide(10.0, 0.0); // Returns: { err: "Division by zero" }
147+
const result = calc.add(5.0, 3.0); // Returns: 8.0
148+
const divided = calc.divide(10.0, 2.0); // Returns: { success: true, error: null, value: 5.0 }
149+
const error = calc.divide(10.0, 0.0); // Returns: { success: false, error: "Division by zero is not allowed", value: null }
150150
```
151151

152152
**The magic:** You write the WIT once, implement it in any language, and it automatically works with every other language.

0 commit comments

Comments
 (0)