dolanmiu / docx

Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
https://docx.js.org/
MIT License
4.06k stars 463 forks source link

Can't add images due to 'type' not existing on 'IImageOptions' #2693

Open vitorMarraHernandes opened 1 week ago

vitorMarraHernandes commented 1 week ago

I'm following the documentation but I can't add images because of the following error:

Object literal may only specify known properties, and 'type' does not exist in type 'IImageOptions'

This happens because the property 'type' doesn't exist in 'IImageOptions'

Here's what my code looks like:

import { AlignmentType, Document, ImageRun, Packer, Paragraph, TextRun, Table } from "docx";
import * as fs from 'fs';

const image = new ImageRun({
        type: 'png',
        data: fs.readFileSync('../../../assets/images/logo_task.png'),
        transformation: {
            width: 150,
            height: 150,
        },
    });
      const doc = new Document({
        sections: [
          {
            children: [
              new Paragraph({
                children: [image]
              }),
              ...

This is pretty much everything the documentation says, what am I missing? Any help would be greatly appreciated