Skip to content
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

Type mismatch between return type of read and crop. #1364

Open
m-haketa opened this issue Dec 11, 2024 · 0 comments
Open

Type mismatch between return type of read and crop. #1364

m-haketa opened this issue Dec 11, 2024 · 0 comments

Comments

@m-haketa
Copy link

m-haketa commented Dec 11, 2024

There is type mismatch between return type of read and crop. I'm not sure if this is the intended behavior.

Expected Behavior

No type error occurs.

Current Behavior

Type Error occurs.

Failure Information (for bugs)

Steps to Reproduce

let base = await Jimp.read('dummy');
let cropped = base.crop({ y: 0, x: 0, h: 100, w: 100 });

//Type error occurs!
base = cropped;

//Type error occurs!
cropped = base;

Context

  • Jimp Version: 1.6.0
  • Operating System: Windows 11 (not using WSL or WSL2)
  • Node version: 22.12.0
  • TypeScript Version: 5.7.2

Failure Logs

base = cropped;

Type 'JimpInstanceMethods<{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: numb...' is not assignable to type '{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: number | undefined): Gen...' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Type 'JimpInstanceMethods<{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: numb...' is not assignable to type '{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: number | undefined): Gen...' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Types of property 'write' are incompatible.
Type '<Extension extends string, Mime extends (Record<"bmp", "image/bmp"> extends infer T ? T extends Record<"bmp", "image/bmp"> ? T extends Record<Extension, infer M> ? M : never : never : never) | (Record<"tiff", "image/tiff"> extends infer T_1 ? T_1 extends Record<"tiff", "image/tiff"> ? T_1 extends Record<Extension, i...' is not assignable to type '<Extension extends string, Mime extends (Record<"bmp", "image/bmp"> extends infer T ? T extends Record<"bmp", "image/bmp"> ? T extends Record<Extension, infer M> ? M : never : never : never) | (Record<"tiff", "image/tiff"> extends infer T_1 ? T_1 extends Record<"tiff", "image/tiff"> ? T_1 extends Record<Extension, i...'. Two different types with this name exist, but they are unrelated.
Types of parameters 'options' and 'options' are incompatible.
Type 'Options | undefined' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type 'Options' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 4 more ... | (Record<...> extends Rec...' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type 'Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '{ palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '{ palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }' is not assignable to type 'Record<"image/png", Omit<any, "filterType" | "colorType" | "inputColorType"> & { filterType?: PNGFilterType; colorType?: PNGColorType; inputColorType?: PNGColorType; }> extends Record<...> ? O : never'.

cropped = base

Type '{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: number | undefined): Gen...' is not assignable to type 'JimpInstanceMethods<{ bitmap: Bitmap; background: number; formats: Format<any, undefined, undefined>[]; mime?: string; inspect(): string; toString(): string; readonly width: number; readonly height: number; ... 10 more ...; scanIterator(x?: number | undefined, y?: number | undefined, w?: number | undefined, h?: numb...' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties.
Type '{ bitmap: import("d:/nodejs/excelspill/node_modules/@jimp/types/dist/esm/index", { with: { "resolution-mode": "import" } }).Bitmap; background: number; formats: import("d:/nodejs/excelspill/node_modules/@jimp/types/dist/esm/index", { with: { "resolution-mode": "import" } }).Format<any, undefined, undefined>[]; ... 1...' is not assignable to type '{ bitmap: import("d:/nodejs/excelspill/node_modules/@jimp/types/dist/esm/index", { with: { "resolution-mode": "import" } }).Bitmap; background: number; formats: import("d:/nodejs/excelspill/node_modules/@jimp/types/dist/esm/index", { with: { "resolution-mode": "import" } }).Format<any, undefined, undefined>[]; ... 1...'. Two different types with this name exist, but they are unrelated.
Types of property 'write' are incompatible.
Type '<Extension extends string, Mime extends (Record<"bmp", "image/bmp"> extends infer T ? T extends Record<"bmp", "image/bmp"> ? T extends Record<Extension, infer M> ? M : never : never : never) | (Record<"tiff", "image/tiff"> extends infer T_1 ? T_1 extends Record<"tiff", "image/tiff"> ? T_1 extends Record<Extension, i...' is not assignable to type '<Extension extends string, Mime extends (Record<"bmp", "image/bmp"> extends infer T ? T extends Record<"bmp", "image/bmp"> ? T extends Record<Extension, infer M> ? M : never : never : never) | (Record<"tiff", "image/tiff"> extends infer T_1 ? T_1 extends Record<"tiff", "image/tiff"> ? T_1 extends Record<Extension, i...'. Two different types with this name exist, but they are unrelated.
Types of parameters 'options' and 'options' are incompatible.
Type 'Options | undefined' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type 'Options' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 4 more ... | (Record<...> extends Rec...' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type 'Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '{ palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }' is not assignable to type '(Record<"image/bmp", { palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }> extends Record<...> ? O : never) | ... 5 more ... | undefined'.
Type '{ palette?: BmpColor[] | undefined; colors?: number | undefined; importantColors?: number | undefined; hr?: number | undefined; vr?: number | undefined; reserved1?: number | undefined; reserved2?: number | undefined; }' is not assignable to type 'Record<"image/png", Omit<any, "filterType" | "colorType" | "inputColorType"> & { filterType?: PNGFilterType; colorType?: PNGColorType; inputColorType?: PNGColorType; }> extends Record<...> ? O : never'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant