Skip to content

Commit

Permalink
🤖 Merge PR #64300 fix(image-blob-reduce): correct type for init optio…
Browse files Browse the repository at this point in the history
…ns by @hazolsky
  • Loading branch information
hazolsky committed Feb 10, 2023
1 parent c21b9f6 commit 0eee833
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 14 additions & 2 deletions types/image-blob-reduce/image-blob-reduce-tests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import * as pica from 'pica';
import * as imageBlobReduce from 'image-blob-reduce';

// no options
// $ExpectType ImageBlobReduce
imageBlobReduce();

// $ExpectType Pica
imageBlobReduce.pica();

// with incorrect options
// @ts-expect-error
imageBlobReduce({ pica: imageBlobReduce.pica });

// with options
const createOptions: imageBlobReduce.Options = {
pica,
pica: imageBlobReduce.pica(),
};

// $ExpectType ImageBlobReduce
const imageReducer = imageBlobReduce(createOptions);

imageReducer.use(
Expand Down
5 changes: 3 additions & 2 deletions types/image-blob-reduce/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Definitions by: Matthias Fischer <https://github.com/dotnetautor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

import type { PicaStatic } from 'pica';
import type { Pica, PicaStatic } from 'pica';

interface InternalProperties {
image: HTMLImageElement;
Expand All @@ -28,7 +28,7 @@ declare namespace imageBlobReduce {
}

interface Options {
pica?: PicaStatic;
pica?: Pica;
}

interface Env extends InternalProperties {
Expand All @@ -48,6 +48,7 @@ declare namespace imageBlobReduce {
interface ImageBlobReduceStatic {
new (options?: Options): ImageBlobReduce;
(options?: Options): ImageBlobReduce;
pica: PicaStatic;
}
}

Expand Down

0 comments on commit 0eee833

Please sign in to comment.