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

New TypeScript definition of 'patch' uses Buffer as a generic #44

Closed
MichalVasak opened this issue May 3, 2021 · 3 comments
Closed

Comments

@MichalVasak
Copy link

Hi @bhousel

This is a minor issue, but I use tsc --pretty in my pipeline and I started getting an error when building a project using the 2.1.1 version of node-diff3, so I have to stay on 2.1.0 until resolved:

"Type 'Buffer' is not generic."

for the new definition of patch in node-diff3/index.d.ts:

"export function patch(buffer: T[], patch: IPatchRes[]): Buffer[];"

Thanks for making this very useful library!

@bhousel
Copy link
Owner

bhousel commented May 3, 2021

Ah, yeah I don't actually use TypeScript at all. I basically just blindly accept any pull request involving the indes.d.ts file 👍

@MichalVasak
Copy link
Author

Ok, I can see the issue, this is the actual line from index.d.ts (not sure why the messages show it as what I put in the original post instead):

export function patch<T>(buffer: T[], patch: IPatchRes<T>[]): Buffer<T>[];

"Buffer" is indeed an attempt to use Buffer as a generic. If the function truly returns an arrray of binary Buffer objects, the correct export would be:

export function patch<T>(buffer: T[], patch: IPatchRes<T>[]): Buffer[];

If the function returns an array of type T, which seems more consistent with the other functions, it would be

export function patch<T>(buffer: T[], patch: IPatchRes<T>[]): T[];

Happy to make the pull request if you want

@bhousel bhousel closed this as completed in ed86801 May 4, 2021
@bhousel
Copy link
Owner

bhousel commented May 4, 2021

Thanks, I went with T[] as the return type.. Just published v2.1.2 with this fix 👍

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

No branches or pull requests

2 participants