more updates

This commit is contained in:
2026-01-28 22:42:47 -05:00
parent e04fe8cef3
commit 234c4718a4
4 changed files with 55 additions and 16 deletions

View File

@@ -102,11 +102,37 @@ That's it! The framework automatically:
- Generates TypeScript definitions
- Manages the qjs integration
### Calling Convention
**Important**: There's an important difference between how functions are defined in Go versus how they're called in JavaScript:
- **Go side**: The function receives a **single argument struct** containing all parameters
- **JavaScript side**: The function is called with the **struct fields as individual arguments** (in the order they appear in the struct)
```go
// Go: Single struct argument
type AddArgs struct {
A int `json:"a"`
B int `json:"b"`
}
func Add(_ context.Context, args AddArgs) (int, error) {
return args.A + args.B, nil
}
```
```typescript
// JavaScript: Individual arguments (not an object!)
const result = add(5, 10); // NOT add({ a: 5, b: 10 })
```
The framework extracts the JSON tags from the struct fields and uses them to generate the correct TypeScript function signature.
### Example
```typescript
// TypeScript code
const response = fetch({input: "https://httpbin.org/get"});
// TypeScript code - call with individual arguments matching struct fields
const response = fetch("https://httpbin.org/get");
console.log("OK:", response.ok);
console.log("Status:", response.status);
console.log("Body:", response.body);