Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module 'mariadb/callback' #298

Open
Hoet opened this issue Oct 24, 2024 · 0 comments
Open

Could not find a declaration file for module 'mariadb/callback' #298

Hoet opened this issue Oct 24, 2024 · 0 comments

Comments

@Hoet
Copy link

Hoet commented Oct 24, 2024

Node version: v22.6.0
Mariadb connector: v3.3.2
Running Debian v12
MariaDB version: 11.5.2-MariaDB-deb12

When trying a little bit of code I get the following error

error TS7016: Could not find a declaration file for module 'mariadb/callback'. 'D:/Programming/Vagrant/sites/test1.test/web/node_modules/mariadb/callback.js' implicitly has an 'any' type.
Try npm i --save-dev @types/mariadb if it exists or add a new declaration (.d.ts) file containing declare module 'mariadb/callback';

Trying to install mariadb types via the suggested command also fails as it is not found.

A side note, running the generated code from the typescript below will display the records in the specified table, but the last two lines are not executed. The application does not seem to continue. I expected it to run, display the 2 rows in the given table and exit.

** Typescript **
`import {createConnection} from "mariadb/callback";

const conn = createConnection({
host: 'localhost',
database: 'database',
user:'username',
password: 'password',
port: 3306
});

conn.connect(err => {
if (err) return console.log("Failed to connect");

console.log(Successfully connected to mariadb server: ${conn.servername});
});

console.log(conn.info);

conn.query("SELECT * from company", (err, rows) => {
console.log('Results:')
console.log(err); //[ {val: 1}, meta: ... ]
console.log(rows); //[ {val: 1}, meta: ... ]
});

conn.end();

console.log('test');
`

** Generated Code **
Object.defineProperty(exports, "__esModule", { value: true }); const callback_1 = require("mariadb/callback"); const conn = (0, callback_1.createConnection)({ host: 'localhost', database: 'databases', user: 'username', password: 'password', port: 3306 }); conn.connect(err => { if (err) return console.log("Failed to connect"); console.log(Successfully connected to mariadb server: ${conn.servername}); }); console.log(conn.info); conn.query("SELECT * from company", (err, rows) => { console.log('Results:'); console.log(err); //[ {val: 1}, meta: ... ] console.log(rows); //[ {val: 1}, meta: ... ] }); conn.end(); console.log('test');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant