sharp icon indicating copy to clipboard operation
sharp copied to clipboard

Bundled, official TypeScript definitions?

Open rexxars opened this issue 1 year ago • 1 comments

Hi Lovell!

I've been helping maintain the @types/sharp module lately, and was wondering if you had any thoughts on whether or not you'd like to see these integrated into (bundled with) the sharp module?

There are a couple of annoyances with having a separate type module:

  • You have to install it separately (duh)
  • Someone (usually not the author of the feature in sharp) has to submit a PR to the types repo, hopefully understanding the changes that have been done in sharp well enough to type them
  • The types often trail the sharp releases, so using the latest version from typescript can be a bit of a pain (having to (sharp as any) things)
  • People tend to add the stuff to the typings that they need to use, but not necessarily all of the features that have been added
  • Sharp is still on the 0.x semver range, which makes it hard for the types module to be versioned properly. If there is a correction to the types, we have to bump the patch version - which often leads to being ahead of sharp in terms of the version number. If sharp follows semver and is on the 1.x or above range, we could provide corrections in patches that theoretically is "ahead" of sharp, but at least follows semver. Example:
    1. Someone sends a PR to fix a typing issue in 0.32.0
    2. The PR is merged and released as @types/[email protected] (sharp is still at 0.32.0, but the types are at 0.32.1)
    3. Sharp adds a new feature and releases 0.32.1
    4. A new PR is merged to add typing support for the feature, and is released as 0.32.2

The situation isn't terrible, but I was wondering if you had any opinion on the matter. I'm sure everyone is happy to continue contributing to the types module, but I'm also sure people would appreciate them being part of the bundle :)

rexxars avatar Sep 15 '22 21:09 rexxars

Hi Espen, thanks for helping to maintain the TypeScript definitions, I'd be happy to make these "official" and integrate into the sharp repo.

The DefinitelyTyped repo is MIT licensed, which should allow us to copy a snapshot of the current implementation and redistribute under Apache 2.0 but with an MIT notice in the definition file.

We should introduce some tooling to help verify types, I'm thinking at least https://www.npmjs.com/package/tsd - anything else you're aware of?

Would including type definitions in the distributed package count as a (slightly) breaking change? If so, we should aim for v0.32.0 rather than a patch release.

lovell avatar Sep 16 '22 08:09 lovell