types / mysql2

Typings for https://github.com/sidorares/node-mysql2
ISC License
41 stars 23 forks source link

Incompatible with ts3.7 #32

Closed mirnpnh closed 4 years ago

mirnpnh commented 4 years ago

Hello, It seems the library can't be used with ts 3.7 due to newly fixed recursive import/export. Actually the recursive import/export is in @types/mysql files but that is affecting this package too.

bluejellybean commented 4 years ago

Here is the error I am seeing on this

tsc --noEmit node_modules/@types/mysql/index.d.ts(2,1): error TS2440: Import declaration conflicts with local declaration of 'Connection'. node_modules/@types/mysql/index.d.ts(4,1): error TS2440: Import declaration conflicts with local declaration of 'PoolConnection'. node_modules/@types/mysql/index.d.ts(5,1): error TS2440: Import declaration conflicts with local declaration of 'Pool'. node_modules/@types/mysql/index.d.ts(7,1): error TS2440: Import declaration conflicts with local declaration of 'PoolCluster'. node_modules/@types/mysql/index.d.ts(9,1): error TS2440: Import declaration conflicts with local declaration of 'Query'. npm ERR! code ELIFECYCLE

jkruse14 commented 4 years ago

I'm seeing the same issue when upgrading typescript from 3.4.3 to 3.7.2. Specifically, I am getting the following:

node_modules/@types/mysql/index.d.ts:2:1 - error TS2440: Import declaration conflicts with local declaration of 'Connection'.

2 import Connection = require('./lib/Connection');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/mysql/index.d.ts:4:1 - error TS2440: Import declaration conflicts with local declaration of 'PoolConnection'.

4 import PoolConnection = require('./lib/PoolConnection');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/mysql/index.d.ts:5:1 - error TS2440: Import declaration conflicts with local declaration of 'Pool'.

5 import Pool = require('./lib/Pool');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/mysql/index.d.ts:7:1 - error TS2440: Import declaration conflicts with local declaration of 'PoolCluster'.

7 import PoolCluster = require('./lib/PoolCluster');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@types/mysql/index.d.ts:9:1 - error TS2440: Import declaration conflicts with local declaration of 'Query'.

9 import Query = require('./lib/protocol/sequences/Query');
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The issue seems to be when defining a variable name via an import statement, i.e.:

import Connection = require('./lib/Connection');

then later exporting the same variable name:

export interface Connection extends Connection {}

is the cause of this issue.

jkruse14 commented 4 years ago

PR with fix: https://github.com/types/mysql/pull/13

theFroh commented 4 years ago

I don't think these typings support types/mysql beyond 2.0.0, so that PR doesn't appear to help (yet)?

theFroh commented 4 years ago

Scratch that, it looks like types/mysql did not change version (minor or otherwise). I can't seem to get types/mysql2 to realise they've updated, though.

kennethaasan commented 4 years ago

You could consider changing the dependency to https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mysql ?

npm install @types/mysql should do

mirnpnh commented 4 years ago

@theFroh how about pointing to an specific commit: github:types/mysql#7d612ffd3f9d81c09df9daac09bb2d49a3c286d0

emilioSp commented 4 years ago

Any news about this? I have the same issue.

bsramin commented 4 years ago

same issue here

jkruse14 commented 4 years ago

This should be all good now with #35 - the master branch for types/mysql is now being pulled in as a dependency rather than the v.2.0.0 branch.

to be sure you get the updated dependencies: rm -rf your node_modules (or just the types/mysql2 folder) delete the package-lock file npm install

emilioSp commented 4 years ago

Now it's working. Thanks!

whiterook6 commented 4 years ago

Sorry to bump a dead topic, but which versions should I have in my package.json file for @types/mysql2? I've tried clearing my node_modules folder, removing and adding @types/mysql2, and I can never seem to get things to line up. Current when I try to add @types/mysql2 yarn tells me it cannot even find the package. Can someone show me what my package.json file should look like?

jkruse14 commented 4 years ago

@whiterook6 - Make sure your package-lock.json is removed, too. We have "mysql2": "^1.3.5", in the dependencies and "@types/mysql2": "github:types/mysql2", in dev dependencies in our package.json

nmitra6 commented 4 years ago

@jkruse14, even with those versions, typescript 3.7 is throwing errors. import xxx = require.....