Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Manual Type Extensions #398

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/create/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ZodType, ZodTypeDef } from 'zod';

import { currentSymbol, previousSymbol } from '../../extendZodTypes';
import { currentSymbol, previousSymbol } from '../../extendZodSymbols';
import type { oas30, oas31 } from '../../openapi3-ts/dist';
import {
type ComponentsObject,
Expand Down
1 change: 1 addition & 0 deletions src/entries/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import { extendZodWithOpenApi } from '../extendZod';

extendZodWithOpenApi(z);

// eslint-disable-next-line @typescript-eslint/consistent-type-exports
export * from '../extendZodTypes'; // compatibility with < TS 5.0 as the export type * syntax is not supported
2 changes: 1 addition & 1 deletion src/extendZod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import { createSchema } from './create/schema/single';
import { extendZodWithOpenApi } from './extendZod';
import { currentSymbol, previousSymbol } from './extendZodTypes';
import { currentSymbol, previousSymbol } from './extendZodSymbols';

extendZodWithOpenApi(z);

Expand Down
3 changes: 2 additions & 1 deletion src/extendZod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ZodRawShape, ZodTypeDef, z } from 'zod';

import { currentSymbol, previousSymbol } from './extendZodTypes';
import './extendZodTypes';
import { currentSymbol, previousSymbol } from './extendZodSymbols';

type ZodOpenApiMetadataDef = NonNullable<ZodTypeDef['zodOpenApi']>;
type ZodOpenApiMetadata = ZodOpenApiMetadataDef['openapi'];
Expand Down
3 changes: 3 additions & 0 deletions src/extendZodSymbols.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// TODO: Remove this file for TS 5.0
export const currentSymbol = Symbol('current');
export const previousSymbol = Symbol('previous');
4 changes: 1 addition & 3 deletions src/extendZodTypes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import type { ZodObject, ZodTypeAny, z } from 'zod';

import type { CreationType } from './create/components';
import type { currentSymbol, previousSymbol } from './extendZodSymbols';
import type { oas30, oas31 } from './openapi3-ts/dist';

type SchemaObject = oas30.SchemaObject & oas31.SchemaObject;

type ReplaceDate<T> = T extends Date ? Date | string : T;

export const currentSymbol = Symbol('current');
export const previousSymbol = Symbol('previous');

/**
* zod-openapi metadata
*/
Expand Down
Loading