@@ -120,15 +120,16 @@ export function gettype (
120120 path = '' ,
121121 literalPaths : string [ ] = [ ] ,
122122 discriminantPaths : string [ ] = [ ] ,
123- recordPaths : string [ ] = [ ]
123+ recordPaths : string [ ] = [ ] ,
124+ omitPaths : string [ ] = [ ] ,
124125) {
125126 if ( typeof json === 'object' ) {
126127 if ( json === null ) return { literal : { value : null } , count : 1 }
127128 if ( Array . isArray ( json ) ) {
128129 if ( json . length === 0 ) return { array : { ...NEVER } , count : 1 }
129130 return {
130131 array : foldleft (
131- json . map ( x => gettype ( x , `${ path } []` , literalPaths , discriminantPaths , recordPaths ) )
132+ json . map ( x => gettype ( x , `${ path } []` , literalPaths , discriminantPaths , recordPaths , omitPaths ) )
132133 ) ,
133134 count : 1
134135 }
@@ -138,8 +139,10 @@ export function gettype (
138139 let keyType : Type = { ...NEVER }
139140 let valueType : Type = { ...NEVER }
140141 for ( const key in json ) {
141- keyType = fold ( keyType , gettype ( key , `${ path } |keys` , literalPaths , discriminantPaths , recordPaths ) )
142- valueType = fold ( valueType , gettype ( json [ key ] , `${ path } []` , literalPaths , discriminantPaths , recordPaths ) )
142+ const innerPath = `${ path } .${ key } `
143+ if ( omitPaths . includes ( innerPath ) ) continue
144+ keyType = fold ( keyType , gettype ( key , `${ path } |keys` , literalPaths , discriminantPaths , recordPaths , omitPaths ) )
145+ valueType = fold ( valueType , gettype ( json [ key ] , `${ path } []` , literalPaths , discriminantPaths , recordPaths , omitPaths ) )
143146 }
144147 return {
145148 record : {
@@ -153,8 +156,10 @@ export function gettype (
153156 const object = { } as Record < string , Type >
154157 let discriminant : Type [ 'literal' ] | undefined
155158 for ( const key in json ) {
156- const ft = gettype ( json [ key ] , `${ path } .${ key } ` , literalPaths , discriminantPaths , recordPaths )
159+ const innerPath = `${ path } .${ key } `
160+ if ( omitPaths . includes ( innerPath ) ) continue
157161
162+ const ft = gettype ( json [ key ] , innerPath , literalPaths , discriminantPaths , recordPaths , omitPaths )
158163 object [ key ] = ft
159164 if ( ft . literal && discriminantPaths . includes ( `${ path } .${ key } ` ) ) {
160165 discriminant = ft . literal
0 commit comments