@@ -421,7 +421,7 @@ export const apply = async ({
421421 const type = typesById . get ( type_id )
422422 let tsType = 'unknown'
423423 if ( type ) {
424- tsType = pgTypeToTsType ( schema , type . name , {
424+ tsType = pgTypeToTsRpcArgType ( schema , type . name , {
425425 types,
426426 schemas,
427427 tables,
@@ -440,7 +440,7 @@ export const apply = async ({
440440 const type = typesById . get ( type_id )
441441 let tsType = 'unknown'
442442 if ( type ) {
443- tsType = pgTypeToTsType ( schema , type . name , {
443+ tsType = pgTypeToTsRpcArgType ( schema , type . name , {
444444 types,
445445 schemas,
446446 tables,
@@ -457,7 +457,7 @@ export const apply = async ({
457457 const type = typesById . get ( type_id )
458458 let tsType = 'unknown'
459459 if ( type ) {
460- tsType = pgTypeToTsType ( schema , type . name , {
460+ tsType = pgTypeToTsRpcArgType ( schema , type . name , {
461461 types,
462462 schemas,
463463 tables,
@@ -972,3 +972,22 @@ export const pgTypeToTsType = (
972972 return 'unknown'
973973 }
974974}
975+
976+ export const pgTypeToTsRpcArgType = (
977+ schema : PostgresSchema ,
978+ pgType : string ,
979+ context : {
980+ types : PostgresType [ ]
981+ schemas : PostgresSchema [ ]
982+ tables : PostgresTable [ ]
983+ views : PostgresView [ ]
984+ }
985+ ) : string => {
986+ if ( pgType === 'int8' ) {
987+ return 'number | bigint'
988+ }
989+ if ( pgType . startsWith ( '_' ) ) {
990+ return `(${ pgTypeToTsRpcArgType ( schema , pgType . substring ( 1 ) , context ) } )[]`
991+ }
992+ return pgTypeToTsType ( schema , pgType , context )
993+ }
0 commit comments