DefinitelyTyped icon indicating copy to clipboard operation
DefinitelyTyped copied to clipboard

Add missing type definitions for package `probe-image-size` deep imports.

Open ddembo opened this issue 1 year ago • 2 comments

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.js
  • probe-image-size/lib/parse_sync/ico.js
  • probe-image-size/lib/parse_sync/png.js
  • probe-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

If changing an existing definition:

  • [X] Provide a URL to documentation or source code which provides context for the suggested changes: bmp.js, ico.js, png.js.
  • [N/A] If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the package.json.

ddembo avatar Jun 25 '24 06:06 ddembo

@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"
}

typescript-bot avatar Jun 25 '24 06:06 typescript-bot

🔔 @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.

typescript-bot avatar Jun 25 '24 06:06 typescript-bot

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!

typescript-bot avatar Jul 06 '24 12:07 typescript-bot

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.)

typescript-bot avatar Jul 13 '24 12:07 typescript-bot

@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!

typescript-bot avatar Jul 15 '24 22:07 typescript-bot

@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?

typescript-bot avatar Jul 22 '24 04:07 typescript-bot

@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?

typescript-bot avatar Jul 23 '24 00:07 typescript-bot

One last question; these entrypoints are not documented by the package at all. Are they intended to be imported like this?

jakebailey avatar Jul 23 '24 17:07 jakebailey

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 avatar Jul 24 '24 00:07 ddembo

@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.)

typescript-bot avatar Jul 24 '24 01:07 typescript-bot

Ready to merge

ddembo avatar Jul 24 '24 01:07 ddembo