Skip to content

Commit

Permalink
feat(parser): remove declarations from types (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac authored Jun 28, 2024
1 parent 10ad753 commit 3728d72
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,22 +253,23 @@ function stripeTypeScriptInternalTypesSchema (type: any): any {
if (Array.isArray(type.schema)) {
return {
...type,
declarations: undefined,
schema: type.schema.map((sch: any) => stripeTypeScriptInternalTypesSchema(sch)).filter((r: any) => r !== false)
}
}

if (!type.schema || typeof type.schema !== 'object') {
return type
return typeof type === 'object' ? { ...type, declarations: undefined } : type
}

const schema: any = {}
Object.keys(type.schema).forEach((sch) => {
if (sch === 'schema' && type.schema[sch]) {
schema[sch] = schema[sch] || {}
Object.keys(type.schema[sch]).forEach((sch2) => {
const res = stripeTypeScriptInternalTypesSchema(type.schema[sch][sch2]);
const res = stripeTypeScriptInternalTypesSchema(type.schema[sch][sch2])
if (res !== false) {
schema[sch][sch2] = res;
schema[sch][sch2] = res
}
})
return
Expand All @@ -282,6 +283,7 @@ function stripeTypeScriptInternalTypesSchema (type: any): any {

return {
...type,
declarations: undefined,
schema
}
}
Expand Down

0 comments on commit 3728d72

Please sign in to comment.