After updating VSCode to version 1.114 (which bundles TypeScript 6), I started getting the following type error when using zod-to-openapi:
Property 'openapi' does not exist on type 'ZodOptional'. ts(2339)
However:
tsc runs without errors
the project builds successfully
runtime behavior is correct
This issue only appears inside the VSCode editor (tsserver), suggesting a compatibility problem with TypeScript 6.
Reproduction
import { z } from "zod";
z.string().optional().openapi({ example: "test" }); // ❌ TS error in VSCode
Expected behavior
.openapi() should be available even after chaining .optional().
Observed behavior
TypeScript (via VSCode tsserver with TS 6) reports that .openapi() does not exist on ZodOptional.
Workarounds
Change method order
z.string().openapi({ example: "test" }).optional(); // ✅ works
Force VSCode to use workspace TypeScript (e.g., TS 5.x)
TypeScript: Select TypeScript Version → Use Workspace Version
Downgrade VSCode (pre-1.114)
Environment
zod: (your version)
zod-to-openapi: (your version)
TypeScript (workspace): e.g. 5.x
VSCode: 1.114
VSCode TypeScript version: 6.0 (bundled)
Notes
This seems related to stricter type inference changes in TypeScript 6 affecting method chaining on wrapped Zod types (ZodOptional, etc.). Possibly the .openapi() extension is not being preserved across chained transformations under the new type system.
After updating VSCode to version 1.114 (which bundles TypeScript 6), I started getting the following type error when using zod-to-openapi:
Property 'openapi' does not exist on type 'ZodOptional'. ts(2339)
However:
tsc runs without errors
the project builds successfully
runtime behavior is correct
This issue only appears inside the VSCode editor (tsserver), suggesting a compatibility problem with TypeScript 6.
Reproduction
import { z } from "zod";
z.string().optional().openapi({ example: "test" }); // ❌ TS error in VSCode
Expected behavior
.openapi() should be available even after chaining .optional().
Observed behavior
TypeScript (via VSCode tsserver with TS 6) reports that .openapi() does not exist on ZodOptional.
Workarounds
Change method order
z.string().openapi({ example: "test" }).optional(); // ✅ works
Force VSCode to use workspace TypeScript (e.g., TS 5.x)
TypeScript: Select TypeScript Version → Use Workspace Version
Downgrade VSCode (pre-1.114)
Environment
zod: (your version)
zod-to-openapi: (your version)
TypeScript (workspace): e.g. 5.x
VSCode: 1.114
VSCode TypeScript version: 6.0 (bundled)
Notes
This seems related to stricter type inference changes in TypeScript 6 affecting method chaining on wrapped Zod types (ZodOptional, etc.). Possibly the .openapi() extension is not being preserved across chained transformations under the new type system.