I have a problem migrating my connection built with JavaScript to Typescript(I have "@types / oracledb": "^5.2.1")
My db.js
const oracledb = require('oracledb');
let dbConfig = require('./dbconfig');
oracledb.initOracleClient({ libDir: 'D:\\MaterialSkywork\\Oracle\\instantclient_21_3' });
console.log(dbConfig)
async function Open(sql, binds, autoCommit) {
let cnn = await oracledb.getConnection(dbConfig);
let result = await cnn.execute(sql, binds, { autoCommit });
cnn.release();
return result;
}
exports.Open = Open;
My connection.ts
const oracledb = require('oracledb');
let dbConfig = require('./dbconfig');
oracledb.initOracleClient({ libDir: 'D:\\MaterialSkywork\\Oracle\\instantclient_21_3' });
console.log(dbConfig)
async function Open(sql, binds, autoCommit) {
let cnn = await oracledb.getConnection(dbConfig);
let result = await cnn.execute(sql, binds, { autoCommit });
cnn.release();
return result;
}
exports.Open = Open;
I have the following errors:
No overload matches this call - let cnn = await OracleDB.getConnection(dbConnection);
TypeError: this.conn.execute is not a function
TypeError: this.conn.release is not a function
I do not understand why my connection in typescript skips several errors.
I tried to follow the steps in this forum on stackoverflow, but there are no properties in @ node / oracledb as they are (IConnection and IPromise)
is there any way to Connect oracledb using typescript ES6 class and module?