Skip to content

Commit 6b76d68

Browse files
committed
refactor: elaborate @saucer-dev/types usage
1 parent b898504 commit 6b76d68

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/content/docs/getting-started/index.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,8 @@ The [GitHub Workflows](https://github.com/saucer/saucer/actions/workflows/build.
106106

107107
For those who plan on using saucer for serving their own frontend, we recommend to install the `@saucer-dev/types` package,
108108
which provides typed abstractions over all saucer functions.
109+
110+
:::caution
111+
When using the typescript package, you should not access saucer functions through `saucer.something` and instead import them from the package.
112+
E.g. instead of using `saucer.call`, import `call` from `import { call } from "@saucer-dev/types";`
113+
:::

src/content/docs/webview/interop.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ In the example shown above, the function would be callable from JavaScript as fo
2828
const result = await saucer.exposed.multiply(5, 10);
2929
```
3030

31+
:::caution
32+
When using the typescript package, define the `multiply` function like this instead:
33+
34+
```ts
35+
import { exposed } from "@saucer-dev/types";
36+
const multiply = exposed<number, [number, number]>("multiply");
37+
```
38+
39+
:::
40+
3141
Function Parameters are automatically type-checked:
3242

3343
```js title="Example: Automatic Type-Checking" frame="terminal" showLineNumbers=false del="[Error]"

0 commit comments

Comments
 (0)