Skip to content

Commit 389b8ec

Browse files
committed
Sync open source content 🐝 (from b28b3c80dff233df1eb6ba77ff3e597ed5ec700c)
1 parent bbd4dc7 commit 389b8ec

File tree

6 files changed

+21
-37
lines changed

6 files changed

+21
-37
lines changed

docs/customize/typescript/react-hooks.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,27 @@ Before using React Hooks, you need to install their dependencies and configure y
120120

121121
### Install required dependencies
122122

123-
The generated SDK with React Hooks has TanStack Query and Zod dependencies that should be listed in the SDK's `package.json`. However, you might need to install them explicitly in your application:
123+
The generated SDK with React Hooks has TanStack Query as a dependency that should be listed in the SDK's `package.json`. Zod is bundled with the SDK. However, you might need to install TanStack Query explicitly in your application:
124124

125125
<CodeWithTabs>
126126
```bash !!tabs npm
127-
npm install @tanstack/react-query zod
127+
npm install @tanstack/react-query
128128
```
129129

130130
```bash !!tabs yarn
131-
yarn add @tanstack/react-query zod
131+
yarn add @tanstack/react-query
132132
```
133133

134134
```bash !!tabs pnpm
135-
pnpm add @tanstack/react-query zod
135+
pnpm add @tanstack/react-query
136136
```
137137

138138
</CodeWithTabs>
139139

140140
<Callout title="Note">
141-
The Speakeasy-generated TypeScript SDK uses Zod for runtime type validation,
142-
and TanStack Query powers the React hooks. These dependencies are required for
143-
the SDK to function correctly.
141+
The Speakeasy-generated TypeScript SDK bundles Zod for runtime type validation,
142+
and TanStack Query powers the React hooks. TanStack Query is required for
143+
the React hooks to function correctly.
144144
</Callout>
145145

146146
### Set up the React Query provider

docs/languages/typescript/methodology-ts.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ export namespace DrinkOrder$ {
326326
```
327327
328328
<Callout title="Note" type="info">
329-
It's important to note that Zod is a peer dependency.
329+
Zod is bundled as a regular dependency in Speakeasy TypeScript SDKs.
330330
331-
The reason for listing Zod as a peer dependency is to use the user's installation of Zod if they have it. Every popular package manager, except for Yarn, says, &quot;If the user doesn't have a peer dependency installed, I'm gonna go ahead and install it and make it available&quot;.
331+
Speakeasy moved Zod from a peer dependency to a regular dependency to address Zod v4 runtime errors. This ensures the SDK always uses its own bundled Zod v3 even if the customer is using Zod v4, preventing version conflicts.
332332
333-
Why does Speakeasy use peer dependencies? There are situations where the `node_modules` tree ends up with multiple Zod versions if the user has a different version of Zod installed than what the SDK requires. For example:
333+
Previously, there were situations where the `node_modules` tree could end up with multiple Zod versions if the user had a different version of Zod installed than what the SDK required. For example:
334334
335335
```text
336336
node_modules/
@@ -340,7 +340,7 @@ node_modules/
340340
zod/ v3.23.5
341341
```
342342
343-
If the SDK throws a Zod validation error, the user might have code like this:
343+
If the SDK threw a Zod validation error, the user might have code like this:
344344
345345
```typescript
346346
import { Sdk } from "sdk";
@@ -360,9 +360,9 @@ try {
360360
}
361361
```
362362
363-
The code at `branch 1` will not evaluate to `true` because the runtime loaded the wrong `ZodError` version. Using peer dependencies helps prevent this Zod validation error.
363+
The code at `branch 1` would not evaluate to `true` because the runtime loaded the wrong `ZodError` version. By bundling Zod as a regular dependency, Speakeasy prevents this validation error and ensures consistent behavior.
364364
365-
Speakeasy SDKs wrap `ZodError`s with a custom error type declared in each SDK. In practice, the Zod error is hidden from users and gets them to only work with the error type exported from the SDK. In the future, we start listing Zod as a direct dependency and are unaware of other Zod installations the user might have.
365+
Speakeasy SDKs wrap `ZodError`s with a custom error type declared in each SDK. In practice, the Zod error is hidden from users and gets them to only work with the error type exported from the SDK.
366366
367367
</Callout>
368368

guides/sdks/typescript-monorepo-tips.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ The most common issue we see is dependency confusion. This happens when develope
1818

1919
### Why is this a problem?
2020

21-
Let's say a developer have Zod installed in their monorepo's root, and their Speakeasy SDK also uses Zod. They might run into a situation where code like this doesn't work:
21+
Let's say a developer has Zod installed in their monorepo's root, and their Speakeasy SDK also uses Zod. With Speakeasy's bundled Zod dependency, this is no longer an issue since the SDK uses its own version of Zod v3, preventing conflicts with user installations of Zod v4.
22+
23+
Previously, developers might have run into a situation where code like this didn't work:
2224

2325
```typescript
2426
try {
@@ -28,13 +30,13 @@ try {
2830
});
2931
} catch (err) {
3032
if (err instanceof ZodError) {
31-
// 🚨 This check fails!
33+
// This check could fail with peer dependencies!
3234
console.log("Validation error:", err.errors);
3335
}
3436
}
3537
```
3638

37-
The `instanceof` check fails because they're importing `ZodError` from a different instance of Zod than what the SDK is using. It's the same code, but JavaScript treats them as different classes.
39+
The `instanceof` check could fail because they were importing `ZodError` from a different instance of Zod than what the SDK was using. By bundling Zod, Speakeasy eliminates this confusion.
3840

3941
### How to fix it
4042

openapi/frameworks/elysia.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -999,13 +999,7 @@ In the SDK `README.md` file, you'll find the documentation for your Speakeasy SD
999999

10001000
Note that the SDK is not ready for production use. To get it production-ready, follow the steps outlined in your Speakeasy workspace.
10011001

1002-
The SDK has Zod as a peer dependency, as can be seen in the `sdk-typescript/package.json` file.
1003-
1004-
Install the required Zod version:
1005-
1006-
```bash Terminal
1007-
npm i zod
1008-
```
1002+
The SDK includes Zod as a bundled dependency, as can be seen in the `sdk-typescript/package.json` file.
10091003

10101004
Replace the code in the `src/main.ts` file with the following example code taken from the `sdk-typescript/docs/sdk/users/README.md` file:
10111005

openapi/frameworks/hono.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -939,13 +939,7 @@ Your SDK documentation includes instructions for installing the MCP server.
939939

940940
Note that the SDK is not ready for production use. To get it production-ready, follow the steps outlined in your Speakeasy workspace.
941941

942-
The SDK has Zod as a peer dependency, as can be seen in the `sdk-typescript/package.json` file.
943-
944-
Install the required Zod version:
945-
946-
```bash Terminal
947-
npm i zod
948-
```
942+
The SDK includes Zod as a bundled dependency, as can be seen in the `sdk-typescript/package.json` file.
949943

950944
Replace the code in the `src/main.ts` file with the following example code taken from the `sdk-typescript/docs/sdks/users/README.md` file:
951945

openapi/frameworks/nestjs.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,7 @@ In the SDK `README.md` file, you'll find documentation about your Speakeasy SDK.
697697

698698
Note that the SDK is not ready for production use. To get it production-ready, follow the steps outlined in your Speakeasy workspace.
699699

700-
The SDK has Zod as a peer dependency, as can be seen in the `sdk-typescript/package.json` file.
701-
702-
Install the required Zod version:
703-
704-
```bash Terminal
705-
npm i zod
706-
```
700+
The SDK includes Zod as a bundled dependency, as can be seen in the `sdk-typescript/package.json` file.
707701

708702
Replace the code in the `src/main.ts` file with the following lines of code:
709703

0 commit comments

Comments
 (0)