Repository navigation
Conversation
…th older @types/node flush, sync, end and copyDone had inferred return types. When the package is built against a recent @types/node, the declaration emitter writes them as Buffer<ArrayBufferLike>, and projects on an older @types/node (where Buffer is not generic) fail with TS2315 just by importing pg. Annotating them as Buffer, like the other serializer functions, makes the emitted .d.ts plain Buffer whatever @types/node the build uses. Fixes brianc#3699
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #3699
Currently the serializer.d.ts that gets published with pg-protocol 1.16.1 types
flush,sync,endandcopyDoneas returningBuffer<ArrayBufferLike>. These are the only 4 functions in the serializer that dont have an explicit return type so the types file will generate whatever your current version of @types/node produces. This will causeTS2315: Type 'Buffer' is not genericwhen trying to import pg on a project that uses an older version of @types/node where Buffer is not generic.This will type those 4 functions as returning
: Buffersimilar to all the other functions in serializer.ts. So that the .d.ts file will output Buffer no matter what version of @types/node you have installed when building. There is no change at runtime.Also added a test to outbound-serializer.test.ts that verifies the serializer.d.ts file does not contain
Buffer<. Currently this test will pass with our lock file using @types/node@16 both before and after this change. But it should detect this issue in the future if someone builds with a newer version of @types/node such as when #3801 gets merged. If you dont want the test I can remove it