Skip to content

Commit

Permalink
[v3] remove explicit ZodError type assertion (#3143)
Browse files Browse the repository at this point in the history
  • Loading branch information
87xie authored Aug 27, 2024
1 parent 7d473b5 commit 1a634cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .changeset/long-islands-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'nextra-theme-blog': patch
'nextra-theme-docs': patch
'nextra': patch
---

remove explicit `ZodError` assertion
8 changes: 3 additions & 5 deletions packages/nextra/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { createRequire } from 'node:module'
import { sep } from 'node:path'
import type { NextConfig } from 'next'
import type { ZodError } from 'zod'
import { fromZodError } from 'zod-validation-error'
import type { Nextra } from '../types'
import {
Expand All @@ -25,11 +24,10 @@ const require = createRequire(import.meta.url)
const AGNOSTIC_PAGE_MAP_PATH = `.next${sep}static${sep}chunks${sep}nextra-page-map`

const nextra: Nextra = nextraConfig => {
try {
nextraConfigSchema.parse(nextraConfig)
} catch (error) {
const { error } = nextraConfigSchema.safeParse(nextraConfig)
if (error) {
logger.error('Error validating nextraConfig')
throw fromZodError(error as ZodError)
throw fromZodError(error)
}

return function withNextra(nextConfig = {}) {
Expand Down

0 comments on commit 1a634cd

Please sign in to comment.