@@ -120,15 +120,16 @@ export function gettype (
120
120
path = '' ,
121
121
literalPaths : string [ ] = [ ] ,
122
122
discriminantPaths : string [ ] = [ ] ,
123
- recordPaths : string [ ] = [ ]
123
+ recordPaths : string [ ] = [ ] ,
124
+ omitPaths : string [ ] = [ ] ,
124
125
) {
125
126
if ( typeof json === 'object' ) {
126
127
if ( json === null ) return { literal : { value : null } , count : 1 }
127
128
if ( Array . isArray ( json ) ) {
128
129
if ( json . length === 0 ) return { array : { ...NEVER } , count : 1 }
129
130
return {
130
131
array : foldleft (
131
- json . map ( x => gettype ( x , `${ path } []` , literalPaths , discriminantPaths , recordPaths ) )
132
+ json . map ( x => gettype ( x , `${ path } []` , literalPaths , discriminantPaths , recordPaths , omitPaths ) )
132
133
) ,
133
134
count : 1
134
135
}
@@ -138,8 +139,10 @@ export function gettype (
138
139
let keyType : Type = { ...NEVER }
139
140
let valueType : Type = { ...NEVER }
140
141
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 ) )
143
146
}
144
147
return {
145
148
record : {
@@ -153,8 +156,10 @@ export function gettype (
153
156
const object = { } as Record < string , Type >
154
157
let discriminant : Type [ 'literal' ] | undefined
155
158
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
157
161
162
+ const ft = gettype ( json [ key ] , innerPath , literalPaths , discriminantPaths , recordPaths , omitPaths )
158
163
object [ key ] = ft
159
164
if ( ft . literal && discriminantPaths . includes ( `${ path } .${ key } ` ) ) {
160
165
discriminant = ft . literal
0 commit comments