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

fix: PoolConnection redundancy when extending Connection interface in TypeScript #1940

Merged
merged 1 commit into from
Apr 13, 2023
Merged

Conversation

wellwelwel
Copy link
Collaborator

@wellwelwel wellwelwel commented Apr 9, 2023

As I mentioned in #1722 issue:

Once the PoolConnection.d.ts has already declared extending the Connection interface:

declare class PoolConnection extends Connection {
    connection: Connection;
    release(): void;
}

Then it doesn't needs to re extend the Connection in index.d.ts #86 like:

export interface PoolConnection extends mysql.PoolConnection, Connection {
  promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
}

Causing the error:

[...] Interface 'PoolConnection' cannot simultaneously extend types 'PoolConnection' and 'Connection'.
  Named property 'execute' of types 'PoolConnection' and 'Connection' are not identical.

86 export interface PoolConnection extends mysql.PoolConnection, Connection {
                    ~~~~~~~~~~~~~~

So, I just removed the Connection from extends in index.d.ts #86 and it will work:

export interface PoolConnection extends mysql.PoolConnection {
  promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
}

As you recommended in #1722:
For this PR, I cloned the master and tested it again in a real use (locally), it works perfectly.


Extra tests:

  • "skipLibCheck": false,
  • "skipLibCheck": true,
  • Also, without skipLibCheck.

@wellwelwel wellwelwel changed the title Fixed the PoolConnection redundancy when extending Connection interface in TypeScript Fix: PoolConnection redundancy when extending Connection interface in TypeScript Apr 11, 2023
@wellwelwel wellwelwel changed the title Fix: PoolConnection redundancy when extending Connection interface in TypeScript fix: PoolConnection redundancy when extending Connection interface in TypeScript Apr 11, 2023
@wellwelwel
Copy link
Collaborator Author

@sidorares Please, let me know if you have any questions or want to change anything 👨🏻‍💻

@sidorares
Copy link
Owner

@wellwelwel thanks for the PR! I'm away with no internet connection for the next 3 days but I'll try to test and merge as soon as I'm back

@sidorares
Copy link
Owner

Actually I think this can be merged right now, LGTM

@sidorares sidorares merged commit 7c62d11 into sidorares:master Apr 13, 2023
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

Successfully merging this pull request may close these issues.

2 participants