File tree Expand file tree Collapse file tree 5 files changed +32
-18
lines changed
Expand file tree Collapse file tree 5 files changed +32
-18
lines changed Original file line number Diff line number Diff line change 1+ # 0.1.6 - 18 Aug 2025
2+ Bug fix:
3+ - handle optional property with special character
4+
15# 0.1.5 - 6 Aug 2025
26Bug fix:
37- [ #23 ] ( https://github.com/elysiajs/exact-mirror/pull/23 ) optional properties not deleted
Original file line number Diff line number Diff line change @@ -2,24 +2,17 @@ import { t } from 'elysia'
22import { createMirror } from '../src/index'
33import { TypeCompiler } from '@sinclair/typebox/compiler'
44
5- const shape = t . Object (
6- {
7- keys : t . Array ( t . Object ( { a : t . Number ( ) } ) )
8- } ,
9- {
10- additionalProperties : true
11- }
12- )
5+ const shape = t . Object ( {
6+ 'is-admin' : t . Union ( [
7+ t . Boolean ( ) ,
8+ t . String ( {
9+ format : 'boolean'
10+ } )
11+ ] )
12+ } )
1313
1414const value = {
15- keys : [
16- {
17- a : 1 ,
18- // @ts -expect-error
19- b : 2
20- }
21- ] ,
22- extra : true
15+ 'is-admin' : true
2316} satisfies typeof shape . static
2417
2518const mirror = createMirror ( shape , {
Original file line number Diff line number Diff line change 11{
22 "name" : " exact-mirror" ,
3- "version" : " 0.1.5 " ,
3+ "version" : " 0.1.6 " ,
44 "description" : " Mirror exact value to TypeBox/OpenAPI model" ,
55 "license" : " MIT" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -495,7 +495,7 @@ const mirror = (
495495 // 63 is '?'
496496 const shouldQuestion =
497497 prop . charCodeAt ( 0 ) !== 63 && schema . type !== 'array'
498- v += `)delete x${ shouldQuestion ? '?' : '' } ${ prop } \n`
498+ v += `)delete x${ shouldQuestion ? ( prop . charCodeAt ( 0 ) === 91 ? '?.' : '?' ) : '' } ${ prop } \n`
499499 }
500500
501501 return `${ v } return x`
Original file line number Diff line number Diff line change @@ -269,4 +269,21 @@ describe('Core', () => {
269269 extra : true
270270 } )
271271 } )
272+
273+ it ( 'handle optional property with special character' , ( ) => {
274+ const shape = t . Object ( {
275+ 'is-admin' : t . Union ( [
276+ t . Boolean ( ) ,
277+ t . String ( {
278+ format : 'boolean'
279+ } )
280+ ] )
281+ } )
282+
283+ const value = {
284+ 'is-admin' : true
285+ } satisfies typeof shape . static
286+
287+ isEqual ( shape , value )
288+ } )
272289} )
You can’t perform that action at this time.
0 commit comments