File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ import { ZodTypeFaker } from './zod-type-faker'
4
4
5
5
export class ZodReadonlyFaker < T extends z . ZodReadonly < z . ZodTypeAny > > extends ZodTypeFaker < T > {
6
6
fake ( ) : z . infer < T > {
7
- return fake ( this . schema . _def . innerType )
7
+ return Object . freeze ( fake ( this . schema . _def . innerType ) )
8
8
}
9
9
}
Original file line number Diff line number Diff line change @@ -2,6 +2,18 @@ import * as z from 'zod'
2
2
import { install , fake } from '../src'
3
3
import { expectType , TypeEqual } from 'ts-expect'
4
4
5
+ test ( 'freeze' , ( ) => {
6
+ const schema = z . object ( { key : z . string ( ) } ) . readonly ( )
7
+
8
+ install ( )
9
+ const data = fake ( schema )
10
+
11
+ expect ( ( ) => {
12
+ // @ts -expect-error
13
+ data . key = 'b'
14
+ } ) . toThrow ( )
15
+ } )
16
+
5
17
test ( 'object' , ( ) => {
6
18
const schema = z . object ( { key : z . string ( ) } ) . readonly ( )
7
19
You can’t perform that action at this time.
0 commit comments