Conversation
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.
Summary
Add
Minipassto thetransformreturn type:ReadEntry | Minipass | null | undefined | false | 0 | ''(same union style as #459). Runtime unpack already pipes a truthy transform result (entry.pipe(tx); tx.pipe(stream)).transformis documented as returning a stream or a falsey value. v7.5.12 narrowed the TypeScript return type fromanytoReadEntry. #459 restored falsey returns (null | undefined | false | 0 | ''), but returning a MiniPass stream still type-errors.MiniPass is what the README tells callers to return;
unpack.tson('data', (chunk: Buffer) => …)stays well-typed. Alternatives: revert the return type toany, or accept Node duplex streams (NodeJS.ReadWriteStream/stream.Duplex). #459 expanded the union to the documented values instead of restoringany. Happy to switch to a wider Node stream type oranyif that is preferred. Node coreTransformstill type-errors after this change.Fixes #462
Test plan
extract({ transform: () => new Minipass({ async: true }) })) type-errors on v7.5.22test/transform-type-check.ts)undefined/falsestill typechecks (transformtype error when falsy value returned #459)npm test -- -c -t0: 21247/21247 assertions pass, includingtest/transform-type-check.tsandtest/unpack.js