Attempting the following transaction in TypeScript resulted in a compile error. The error message stated:
Type 'Promise<void>' is not assignable to type 'Promise<transactionArgument>'
. However, the function returns a value of type transaction
, which is of type transactionArgument
.
I am puzzled by this issue and would greatly appreciate any insights or opinions on why it occurred.
type RegisterPricingTransactionInfo = (pricingTransaction:transactionArgument,createdAt:Date,createdBy:string,datasource:any) => Promise<transactionArgument>
export const registerPricingTransactionInfo: RegisterPricingTransactionInfo = async (pricingTransaction,createdAt,createdBy,datasource) => {
let urlCode;
let transaction:transactionArgument;
transaction = {test:"test"}
await datasource.manager.transaction(async (transactionalEntityManager:EntityManager) =>{
try {
await transactionalEntityManager.save(transaction)
return transaction;
} catch (error) {
console.error(error)
}
})
}
"message": "Type '(pricingTransaction: transactionArgument, createdAt: Date, createdBy: string, datasource: any) => Promise<void>' is not assignable to type 'RegisterPricingTransactionInfo'.\n Type 'Promise<void>' is not assignable to type 'Promise<transactionArgument>'.\n Type 'void' is not assignable to type 'transactionArgument'."
Thank you for your help.