refactor: unifies spread types in their proper places #2067
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It's a large TypeScript refactoring that includes every single
*.tsfile in the entire project.Why?
Many types are confusing because they are redefined several times, for example:
Pooltypes are spread and defined inindex.d.ts,typings/mysql/index.d.tsandtypings/mysql/lib/Pool.d.tsat the same timeConnection,ConnectionOptions,execute,query, etc.executeandqueryare complex and have to do several ctrl + c and v around the typesTo consider
Connection? It's simple: go toConnection.d.tsfile 👨🏻💻CI
npm run lint:codenow checks for every*.tsfile (including the tests)What does this refactoring change?
✅ These changes resolves 100% of
eslinterrors in*.ts✅ Unifies the types in their proper places:
Poolas example: now, all typings are defined intypings/mysql/lib/Pool.d.tsexecuteandqueryoverloads too. Now both can be reused:executeorquery, it will automatically affect all types that need it (Connection,PoolConnection, etc.) 🤹🏻♀️✅ Increments
NodeNextTypeScript compatibility by requires the.jsin local imports for*.tsfiles✅ Resolves circular imports in every
*.tsfile✅ Patterns all imports as
import any from './'import any = require('./')ℹ️ Removes older TypeScript tests that are unused
@types/mocha,@types/chai,mochaandchaidependenciesLastly
It's the new index.d.ts: