node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

TypeError: FieldPacket type can't be used to access mysql.Types

Open spiros132 opened this issue 11 months ago • 3 comments

When trying to access the Type of a certain field through the FieldPacket interface I get the following error in vs code: image

I've tried using the type field and the column type field, but both are returning an error in the IDE. If I try to run the code with "npm run dev" it doesn't have any errors and returns the type correctly.

spiros132 avatar Dec 11 '24 13:12 spiros132

Hi @spiros132, could you provide a simple code example to reproduce this warning?

wellwelwel avatar Dec 11 '24 13:12 wellwelwel

The following code returns the above error for me

import mysql from "mysql2";

export function Test(fields: mysql.FieldPacket[]) {
    if(fields[0].type != undefined)
        type: mysql.Types = mysql.Types[fields[0].type];
}

spiros132 avatar Dec 11 '24 15:12 spiros132

I'm also facing this after upgrading to ESM.

KrisBraun avatar Apr 21 '25 19:04 KrisBraun