`transform` type error when stream value returned
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 922
- Forks
- 281
- PR merge metrics
- No merged PRs in 30d
Description
The transform option used to support a stream return value, and is still documented as such:
transformProvide a function that takes anentryobject, and returns a stream, or any falsey value.
However, the return type of this option was changed from any to ReadEntry in v7.5.12 (in this commit).
v7.5.12:
https://github.com/isaacs/node-tar/blob/2a294d3fbb24c18dc80f31059f49dd9af15653fe/src/options.ts#L240
v7.5.11:
https://github.com/isaacs/node-tar/blob/bf776f673164215074b62749e0fe80e5834588f4/src/options.ts#L242
A similar type error was reported in #459, regarding a falsey return value. That was fixed, but a stream return value still produces a type error today.
Specifically I encountered this error when returning a MiniPass stream, as the README suggested.
MInimal reproduction (valid with v7.5.11, raises type error with v7.5.12):
import { extract } from 'tar'
import { Minipass } from 'minipass';
export const repro = (fileList: string[]): ReturnType<typeof extract> => {
return extract(
{
// Type error:
// Type '() => Minipass<Buffer, Buffer, Minipass.Events<Buffer>>' is not assignable to type '(entry: ReadEntry) => ReadEntry'.
transform: () => {
return new Minipass({ async: true });
},
},
fileList,
);
};
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/options.ts at the transform option type and compare the v7.5.11 and v7.5.12 definitions linked in the issue. Use the provided TypeScript reproduction with a MiniPass return value to verify the type accepts the documented stream return without reintroducing the falsey-value regression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100