Skip to content

Commit da92bc0

Browse files
tresoramagemini-code-assist[bot]dinwwwh
authored
docs: improve "Router to Contract" (#752)
I haven't tested it. Only written the result of this Github Discussion https://github.com/unnoq/orpc/discussions/696 Closes: https://github.com/unnoq/orpc/issues/732 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Improved guidance on TypeScript typing for imported contract JSON, including a safer example that preserves type inference and type safety when using contracts on the client side. * Added a warning note explaining the necessity of manual casting due to JSON serialization limitations of standard schema types. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: unnoq <contact@unnoq.com>
1 parent f356b86 commit da92bc0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

apps/content/docs/contract-first/router-to-contract.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ However, if you're deriving the contract from a [router](/docs/router), importin
4545
```ts
4646
import contract from './contract.json' // [!code highlight]
4747
48-
const link = new OpenAPILink(contract as any, {
48+
const link = new OpenAPILink(contract as typeof router, {
4949
url: 'http://localhost:3000/api',
5050
})
5151
```
52+
53+
::: warning
54+
Cast `contract` to `typeof router` to ensure type safety, since standard schema types cannot be serialized to JSON so we must manually cast them.
55+
:::

0 commit comments

Comments
 (0)