Add missing type definitions for package `probe-image-size` deep imports.
What's changed?
When directly deep importing the parsing functions from probe-image-size/lib/parse_sync, e.g. png.js, ico.js, etc, TypeScript does not infer narrow enough types for the argument or return types.
This PR adds type definitions for the following functions, and ensures return types that are more narrow than what TypeScript infers:
probe-image-size/lib/parse_sync/bmp.jsprobe-image-size/lib/parse_sync/ico.jsprobe-image-size/lib/parse_sync/png.jsprobe-image-size/stream.js
Also added some test cases for the above, to probe-image-size-tests.ts.
Unfortunately, I cannot allocate any more time towards adding types & tests for the other parse functions and for now this will need to be done by other members of the community.
Checklist
- [X] Use a meaningful title for the pull request. Include the name of the package modified.
- [X] Test the change in your own code. (Compile and run.)
- [X] Add or edit tests to reflect the change.
- [X] Follow the advice from the readme.
- [X] Avoid common mistakes.
- [X] Run
pnpm test <package to test>.
If changing an existing definition:
@ddembo Thank you for submitting this PR!
This is a live comment that I will keep updated.
1 package in this PR
Code Reviews
Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.
You can test the changes of this PR in the Playground.
Status
- ✅ No merge conflicts
- ✅ Continuous integration tests have passed
- ✅ Most recent commit is approved by type definition owners, DT maintainers or others
All of the items on the list are green. To merge, you need to post a comment including the string "Ready to merge" to bring in your changes.
Diagnostic Information: What the bot saw about this PR
{
"type": "info",
"now": "-",
"pr_number": 69899,
"author": "ddembo",
"headCommitOid": "144092d239566f8dd1f8dd3c4953b3ab74356cda",
"mergeBaseOid": "a095aae4a45006fa4383301f297856940da699c0",
"lastPushDate": "2024-06-25T06:56:00.000Z",
"lastActivityDate": "2024-07-24T01:18:05.000Z",
"mergeOfferDate": "2024-07-24T01:09:02.000Z",
"mergeRequestDate": "2024-07-24T01:18:05.000Z",
"mergeRequestUser": "ddembo",
"hasMergeConflict": false,
"isFirstContribution": false,
"tooManyFiles": false,
"hugeChange": false,
"popularityLevel": "Well-liked by everyone",
"pkgInfo": [
{
"name": "probe-image-size",
"kind": "edit",
"files": [
{
"path": "types/probe-image-size/lib/parse_sync/bmp.d.ts",
"kind": "definition"
},
{
"path": "types/probe-image-size/lib/parse_sync/ico.d.ts",
"kind": "definition"
},
{
"path": "types/probe-image-size/lib/parse_sync/png.d.ts",
"kind": "definition"
},
{
"path": "types/probe-image-size/probe-image-size-tests.ts",
"kind": "test"
},
{
"path": "types/probe-image-size/stream.d.ts",
"kind": "definition"
},
{
"path": "types/probe-image-size/tsconfig.json",
"kind": "package-meta-ok"
}
],
"owners": [
"jineshshah36",
"peterblazejewicz"
],
"addedOwners": [],
"deletedOwners": [],
"popularityLevel": "Well-liked by everyone"
}
],
"reviews": [
{
"type": "approved",
"reviewer": "jakebailey",
"date": "2024-07-24T01:08:24.000Z",
"isMaintainer": true
}
],
"mainBotCommentID": 2188124409,
"ciResult": "pass"
}
🔔 @jineshshah36 @peterblazejewicz — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.
Re-ping @jineshshah36, @peterblazejewicz:
This PR has been out for over a week, yet I haven't seen any reviews.
Could someone please give it some attention? Thanks!
It has been more than two weeks and this PR still has no reviews.
I'll bump it to the DT maintainer queue. Thank you for your patience, @ddembo.
(Ping @jineshshah36, @peterblazejewicz.)
@ddembo One or more reviewers has requested changes. Please address their comments. I'll be back once they sign off or you've pushed new commits. Thank you!
@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?
@jakebailey Thank you for reviewing this PR! The author has pushed new commits since your last review. Could you take another look and submit a fresh review?
One last question; these entrypoints are not documented by the package at all. Are they intended to be imported like this?
I can only speculate about what the creator intended or not, but the first key feature is small size, no heavy dependencies and I think that deep-importing individual functions is a manifestation that philosophy. Also further down in the API section, they further seem to encourage deep importing:
You can access/browserify stream.js / http.js / sync.js directly.
@ddembo: Everything looks good here. I am ready to merge this PR (at 144092d) on your behalf whenever you think it's ready.
If you'd like that to happen, please post a comment saying:
Ready to merge
and I'll merge this PR almost instantly. Thanks for helping out! :heart:
(@jineshshah36, @peterblazejewicz: you can do this too.)
Ready to merge