Open
Description
Issue
The DOM definition of ImageData
right now includes a new field called colorSpace which is not present in the current definition of ImageData
of node-canvas. As a result when I compile the jest test which uses node-canvas I get the following erro in typescript:
"Argument of type 'import(\"/..../node_modules/canvas/types/index\").ImageData' is not assignable to parameter of type 'ImageData'.\n Property 'colorSpace' is missing in type 'import(\"/.../node_modules/canvas/types/index\").ImageData' but required in type 'ImageData'."
Steps to Reproduce
- Generate a simple react app :
npx create-react-app my-app --template typescript
- Add node canvas for regression testing :
npm i -D canvas
- under the
src
folder createcropImage.ts
as follow:
export default function cropImage(imageData : ImageData ) : ImageData {
return imageData;
}
- under the
src
folder createcropImage.test.ts
as follow:
import cropImage from './cropImage'
import {ImageData} from 'canvas';
describe('cropImage', ()=>{
test('shall crop the image', ()=>{
const imgData = new ImageData(10,10);
const resData = cropImage(imgData);
expect(resData).not.toBeNull();
})
});
- in Visual Studio code the editor will highlight
imgData
as invalid type (but the test passes):

Your Environment
- Version of node-canvas (output of
npm list canvas
oryarn list canvas
):
├── [email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ @jest/[email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└── [email protected] deduped
- Environment (e.g. node 20.9.0 on macOS 14.1.1): v20.12.2