@@ -91,7 +91,17 @@ describe('常规', () => {
9191 test ( '动态对象属性' , ( ) => {
9292 expect (
9393 parseSchema ( docs , { type : 'object' , additionalProperties : { type : 'string' } } ) ,
94- ) . toMatchInlineSnapshot ( `"({ [key: string]: (string) })"` ) ;
94+ ) . toMatchInlineSnapshot ( `"({ } & { [key: string]: (string) })"` ) ;
95+
96+ expect (
97+ parseSchema ( docs , {
98+ type : 'object' ,
99+ properties : { foo : { type : 'string' } , bar : { type : 'boolean' } } ,
100+ additionalProperties : { type : 'string' } ,
101+ } ) ,
102+ ) . toMatchInlineSnapshot (
103+ `"({ "foo"?: (string);"bar"?: (boolean) } & { [key: string]: (string) })"` ,
104+ ) ;
95105
96106 expect (
97107 parseSchema ( docs , {
@@ -100,10 +110,23 @@ describe('常规', () => {
100110 type : 'object' ,
101111 properties : { foo : { type : 'string' } , bar : { type : 'number' } } ,
102112 } ,
113+ nullable : true ,
103114 } ) ,
104115 ) . toMatchInlineSnapshot (
105- `"({ [key: string]: ({ "foo"?: (string);"bar"?: (number) }) })"` ,
116+ `"({ } & { [key: string]: ({ "foo"?: (string);"bar"?: (number) }) } | null )"` ,
106117 ) ;
118+
119+ expect (
120+ parseSchema ( docs , { type : 'object' , additionalProperties : true } ) ,
121+ ) . toMatchInlineSnapshot ( `"({ } & { [key: string]: unknown; })"` ) ;
122+
123+ expect (
124+ parseSchema ( docs , { type : 'object' , additionalProperties : false } ) ,
125+ ) . toMatchInlineSnapshot ( `"({ })"` ) ;
126+
127+ expect (
128+ parseSchema ( docs , { type : 'object' , additionalProperties : undefined } ) ,
129+ ) . toMatchInlineSnapshot ( `"({ })"` ) ;
107130 } ) ;
108131} ) ;
109132
0 commit comments