Skip to content

Commit

Permalink
fix record type
Browse files Browse the repository at this point in the history
  • Loading branch information
prostgles committed Oct 12, 2023
1 parent a84fbf2 commit b0e5f91
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/JSONBValidation/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ export function getJSONBSchemaTSTypes(schema: JSONB.JSONBSchema, colOpts: ColOpt

} else if (fieldType?.record) {
const { keysEnum, values, partial } = fieldType.record;
// TODO: ensure props with undefined values are not allowed in the TS type
// TODO: ensure props with undefined values are not allowed in the TS type (strict union)
const getRecord = (v: string) => partial? `Partial<Record<${v}>>` : `Record<${v}>`;
return `${fieldType.nullable ? `null |` : ""} ${getRecord(`${keysEnum?.map(v => asValue(v)).join(" | ") ?? "string"}, ${!values? "any" : getFieldType(values, true, undefined, depth + 1)}`)}>>`
return `${fieldType.nullable ? `null |` : ""} ${getRecord(`${keysEnum?.map(v => asValue(v)).join(" | ") ?? "string"}, ${!values? "any" : getFieldType(values, true, undefined, depth + 1)}`)}`

} else if(fieldType?.lookup){

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prostgles-server",
"version": "4.1.85",
"version": "4.1.86",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion tests/client/PID.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1750441
1754269
2 changes: 1 addition & 1 deletion tests/server/DBoGenerated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export type DBSchemaGenerated = {
| { ok: string; }
| { err: string; }
| { loading: { loaded: number; total: number; }; }
table_config?: null | { referencedTables?: ( { name: string; minFiles: number; } )[]; recType?: null | Record<'a' | 'b', { bools: boolean[]; }>>>; };
table_config?: null | { referencedTables?: ( { name: string; minFiles: number; } )[]; recType?: null | Record<'a' | 'b', { bools: boolean[]; }>; };
};
};
tr1: {
Expand Down
2 changes: 1 addition & 1 deletion tests/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b0e5f91

Please sign in to comment.