Skip to content

Commit

Permalink
Fix Manual Type Extensions (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
samchungy authored Dec 25, 2024
1 parent 865c0a3 commit a9e19ea
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
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

0 comments on commit a9e19ea

Please sign in to comment.