I have a nodejs typescript project that requires the use of mysqljs (https://www.npmjs.com/package/mysql), I've imported the DefinitelyTyped package (https://www.npmjs.com/package/@types/mysql) and included them in my tsconfig file
tsconfig.json
{ "compilerOptions": { "noImplicitAny": false, "module": "commonjs", "noEmitOnError": true, "removeComments": false, "sourceMap": true, "target": "es6" }, "exclude": [ "node_modules" ], "typeRoots": [ "node_modules/@types", "Scripts/typings/node" ], "types": [ "mysql", "node" ] }
I can correctly use the mysql module functions but I cannot access the types (IConnection, IQuery, etc). I can also see the parameter and return types from intellisense.
Example
import * as mysql from 'mysql'
...
getUser(username: string): User {
mysql.createConnection({ host: "...", user: "...", password: "..." });
}
But I'd like to make a method that returns a type defined in the mysql typings (IQuery for example)
Something like
getUser(username:string): IQuery{
}
Being a beginner in typescript coming from a c# background, I don't see what's going on here.
Thanks for the help.
EDIT:
I have tried prefixing he type without any success as well as importing through this format import {IConnection} from 'mysql'
Thanks again.