Skip to content

Commit

Permalink
disallow nullable and optional as base types, fix action
Browse files Browse the repository at this point in the history
  • Loading branch information
iway1 committed Jan 1, 2023
1 parent bcce5d1 commit 1f0312f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
registry-url: https://registry.yarnpkg.com/
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ts-react/form",
"version": "1.0.0",
"version": "1.0.1",
"description": "Build forms faster!",
"module": "lib/index.mjs",
"main": "lib/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/createSchemaForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ describe("createSchemaForm", () => {
it("should throw a duplicate type error if multiple of the same schema are passed.", () => {
const mapping = [
[z.string(), () => <div />] as const,
[z.string().optional(), () => <div />] as const,
[z.string(), () => <div />] as const,
] as const;

expect(() => createTsForm(mapping)).toThrowError(duplicateTypeError());
Expand Down
4 changes: 2 additions & 2 deletions src/createSchemaForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { IndexOf, RequireKeysWithRequiredChildren } from "./typeUtilities";
import { getMetaInformationForZodType } from "./getMetaInformationForZodType";
import { unwrapEffects, UnwrapZodType } from "./unwrap";
import { RTFSupportedZodTypes } from "./supportedZodTypes";
import { RTFBaseZodType, RTFSupportedZodTypes } from "./supportedZodTypes";
import { FieldContextProvider } from "./FieldContext";
import { isZodTypeEqual } from "./isZodTypeEqual";

Expand All @@ -33,7 +33,7 @@ export type ReactComponentWithRequiredProps<
| (ForwardRefExoticComponent<Props> & RefAttributes<unknown>);

export type MappingItem<PropType extends ReactProps> = readonly [
RTFSupportedZodTypes,
RTFBaseZodType,
ReactComponentWithRequiredProps<PropType>
];

Expand Down
9 changes: 6 additions & 3 deletions src/supportedZodTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
/**
* Reducing this helps with TS performance
*/
export type RTFSupportedZodTypes =
export type RTFBaseZodType =
| ZodString
| ZodNumber
| ZodBoolean
Expand All @@ -33,7 +33,10 @@ export type RTFSupportedZodTypes =
| ZodMap<any>
| ZodSet<any>
| ZodEnum<any>
| ZodOptional<any>
| ZodNullable<any>
| ZodBranded<any, any>
| ZodEffects<any, any>;

export type RTFSupportedZodTypes =
| RTFBaseZodType
| ZodOptional<any>
| ZodNullable<any>;

0 comments on commit 1f0312f

Please sign in to comment.