Skip to content

Promises not working? #11

@fdcastel

Description

@fdcastel

This code (from promises sample)

import * as mysql from 'mysql2/promise';

let connection = mysql.createConnection(process.env['DB']);

connection.connect()
    .then(() => connection.query<mysql.RowDataPacket[]>('SELECT 1 + 1 AS solution'))
    .then(([rows, fields]) => {
        console.log('The solution is: ', rows[0]['solution']);
    });

Is causing he following error in runtime:

TypeError: connection.connect is not a function

Please, do notice the error occurs just in runtime. The TypeScript compiler doesn't shows any errors.

Using TypeScript version 2.3.2, Node.js version v6.10.3 and mysql2 version 1.2.0 (tried to downgrade to 1.1.1 but the problem remains).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions