Skip to content

Commit

Permalink
fix(zodKeys): fix typing & remove lint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
chohner committed Dec 17, 2024
1 parent 47fb57e commit 5880311
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export default tseslint.config(
],

// TODO: to be enabled later
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/array-type": "off",

Expand Down
2 changes: 0 additions & 2 deletions tests/integration/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ describe("integration testing helper functions", () => {
});

it("should return an empty array when schema is null or undefined", () => {
// @ts-expect-error
expect(zodKeys(null)).toEqual([]);
// @ts-expect-error
expect(zodKeys(undefined)).toEqual([]);
});

Expand Down
4 changes: 3 additions & 1 deletion tests/integration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export function compileAllStrapiPages(
* Massive if branching is needed, as Zod has different ways of encoding
* a schema's keys for each data type
*/
export function zodKeys<T extends z.ZodTypeAny>(schema: T): string[] {
export function zodKeys<T extends z.ZodTypeAny | null | undefined>(
schema: T,
): string[] {
// make sure schema is not null or undefined
if (schema === null || schema === undefined) return [];
// check if schema is nullable or optional
Expand Down

0 comments on commit 5880311

Please sign in to comment.