Skip to content

Commit 1a634cd

Browse files
authoredAug 27, 2024··
[v3] remove explicit ZodError type assertion (#3143)
1 parent 7d473b5 commit 1a634cd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed
 

‎.changeset/long-islands-report.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'nextra-theme-blog': patch
3+
'nextra-theme-docs': patch
4+
'nextra': patch
5+
---
6+
7+
remove explicit `ZodError` assertion

‎packages/nextra/src/server/index.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { createRequire } from 'node:module'
33
import { sep } from 'node:path'
44
import type { NextConfig } from 'next'
5-
import type { ZodError } from 'zod'
65
import { fromZodError } from 'zod-validation-error'
76
import type { Nextra } from '../types'
87
import {
@@ -25,11 +24,10 @@ const require = createRequire(import.meta.url)
2524
const AGNOSTIC_PAGE_MAP_PATH = `.next${sep}static${sep}chunks${sep}nextra-page-map`
2625

2726
const nextra: Nextra = nextraConfig => {
28-
try {
29-
nextraConfigSchema.parse(nextraConfig)
30-
} catch (error) {
27+
const { error } = nextraConfigSchema.safeParse(nextraConfig)
28+
if (error) {
3129
logger.error('Error validating nextraConfig')
32-
throw fromZodError(error as ZodError)
30+
throw fromZodError(error)
3331
}
3432

3533
return function withNextra(nextConfig = {}) {

0 commit comments

Comments
 (0)
Please sign in to comment.