Row is possibly undefined
woowenjun99 opened this issue · 2 comments
woowenjun99 commented
This is not a bug but more of an annoying issue. Upon generating the TypeScript file, there is an issue where row might be undefined during const row = result.rows[0];. One simple solution would be to typecast by editing the generated file, but it is not really ideal. Would there be a better solution to this?

kyleconroy commented
We can update the generated code with an additional if statement. Can you edit the code to add the following if statement and see if things are fixed?
if (result.rows.length !== 1) {
return null;
}
const row = result.rows[0];
if (!row) {
return null;
}
return {
id: row[0],
name: row[1],
bio: row[2]
};woowenjun99 commented
