Skip to content

feat: Add strict types and TSDocs to ImageScript.d.ts #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 1, 2025

Conversation

acdvorak
Copy link
Contributor

This PR adds detailed type declarations and TSDoc comments for all exported members, including default values.

It also adds several new type and interface exports for ease of use.

E.g.:

/**
 * - `0` = **lowest** quality (smallest file size)
 * - `100` = **highest** quality (largest file size)
 */
export type JPEGQuality =
  | 1
  | 2
  | 3
  // ...
  | 98
  | 99
  | 100;

export class Image {
  // ...

  /**
   * Encodes the image into a JPEG.
   *
   * @param quality `1`-`100`, where `1` is lowest quality (highest compression)
   *     and `100` is highest quality (lowest compression). Default: `90`
   */
  async encodeJPEG(quality?: JPEGQuality): Promise<Uint8Array>;

  private toString(): `Image<${number}x${number}>`;

  // ...
}

This PR adds detailed type declarations and TSDoc comments for all exported members, as well as several new `type` and `interface` exports for ease of use.

E.g.:

```ts
export class Image {
  // ...

  /**
   * Encodes the image into a JPEG.
   *
   * @param quality `1`-`100`, where `1` is lowest quality (highest compression)
   *     and `100` is highest quality (lowest compression). Default: `90`
   */
  async encodeJPEG(quality?: JPEGQuality): Promise<Uint8Array>;

  // ...
}

/**
 * - `0` = **lowest** quality (smallest file size)
 * - `100` = **highest** quality (largest file size)
 */
export type JPEGQuality =
  | 1
  | 2
  | 3
  // ...
  | 98
  | 99
  | 100;
```
@matmen matmen self-requested a review May 23, 2025 06:25
@matmen matmen added documentation Improvements or additions to documentation enhancement New feature or request labels May 23, 2025
Copy link
Owner

@matmen matmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@matmen matmen merged commit be81903 into matmen:dev Jun 1, 2025
13 checks passed
matmen pushed a commit that referenced this pull request Jun 1, 2025
This PR adds detailed type declarations and TSDoc comments for all exported members, as well as several new `type` and `interface` exports for ease of use.

E.g.:

```ts
export class Image {
  // ...

  /**
   * Encodes the image into a JPEG.
   *
   * @param quality `1`-`100`, where `1` is lowest quality (highest compression)
   *     and `100` is highest quality (lowest compression). Default: `90`
   */
  async encodeJPEG(quality?: JPEGQuality): Promise<Uint8Array>;

  // ...
}

/**
 * - `0` = **lowest** quality (smallest file size)
 * - `100` = **highest** quality (largest file size)
 */
export type JPEGQuality =
  | 1
  | 2
  | 3
  // ...
  | 98
  | 99
  | 100;
```
matmen pushed a commit that referenced this pull request Jun 1, 2025
This PR adds detailed type declarations and TSDoc comments for all exported members, as well as several new `type` and `interface` exports for ease of use.

E.g.:

```ts
export class Image {
  // ...

  /**
   * Encodes the image into a JPEG.
   *
   * @param quality `1`-`100`, where `1` is lowest quality (highest compression)
   *     and `100` is highest quality (lowest compression). Default: `90`
   */
  async encodeJPEG(quality?: JPEGQuality): Promise<Uint8Array>;

  // ...
}

/**
 * - `0` = **lowest** quality (smallest file size)
 * - `100` = **highest** quality (largest file size)
 */
export type JPEGQuality =
  | 1
  | 2
  | 3
  // ...
  | 98
  | 99
  | 100;
```
matmen pushed a commit that referenced this pull request Jun 1, 2025
This PR adds detailed type declarations and TSDoc comments for all exported members, as well as several new `type` and `interface` exports for ease of use.

E.g.:

```ts
export class Image {
  // ...

  /**
   * Encodes the image into a JPEG.
   *
   * @param quality `1`-`100`, where `1` is lowest quality (highest compression)
   *     and `100` is highest quality (lowest compression). Default: `90`
   */
  async encodeJPEG(quality?: JPEGQuality): Promise<Uint8Array>;

  // ...
}

/**
 * - `0` = **lowest** quality (smallest file size)
 * - `100` = **highest** quality (largest file size)
 */
export type JPEGQuality =
  | 1
  | 2
  | 3
  // ...
  | 98
  | 99
  | 100;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants