Jspdf-autotable: CellDefinition's content type is wrong

Created on 15 Nov 2019  Â·  5Comments  Â·  Source: simonbengtsson/jsPDF-AutoTable

I'm using jsPDF in my project and I'm creating a CellDefinition object like below

  const TableHeading: CellDefinition[] = [
    {
      content: "Title One",
      colSpan: 2
    },
    {
      content: "Title Two",
      colSpan: 2
    }
  ];

I'm getting a typescript error because Type 'string' is not assignable to type 'Styles | undefined'.ts(2322)

It looks like this is the issue:

interface CellDefinition {
    rowSpan?: number,
    colSpan?: number,
    styles?: Styles,
    content?: Styles,
}

I imagine that content shouldn't be of type Styles. I'll be happy to make a PR to update this if you're happy to confirm the type it should be.

Thanks for making this package. It's exactly what I need for my project!

-A

All 5 comments

It should not be a string? Rather a styles object?

On Fri, 15 Nov 2019 at 09:08, Andrico notifications@github.com wrote:

If you have a question of how to use this plugin, please post on
StackOverflow with the tags jspdf and jspdf-autotable.

I'm using jsPDF in my project and I'm creating a CellDefinition object
like below

const TableHeading: CellDefinition[] = [
{
content: "Title One",
colSpan: 2
},
{
content: "Title Two",
colSpan: 2
}
];

I'm getting a typescript error because Type 'string' is not assignable to
type 'Styles | undefined'.ts(2322)

It looks like this is the issue:

interface CellDefinition {
rowSpan?: number,
colSpan?: number,
styles?: Styles,
content?: Styles,
}

I imagine that content shouldn't be of type Styles. I'll be happy to make
a PR to update this if you're happy to confirm the type it should be.

Thanks for making this package. It's exactly what I need for my project!

-A

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/simonbengtsson/jsPDF-AutoTable/issues/576?email_source=notifications&email_token=AA3LVA5VYPJZDNDSEO74V43QTZKIVA5CNFSM4JNXDMX2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HZRGDWA,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA3LVA4QC3PA5B7RVM6F2BTQTZKIVANCNFSM4JNXDMXQ
.

I'm sure it shouldn't be of type Styles, it should be string but according to this line :
https://github.com/simonbengtsson/jsPDF-AutoTable/blob/e5bdf556dff97bd2c655d06c85d005276b0d7a38/src/models.ts#L157

It can be some type of an object with a title property, I'm not sure what object this line is accounting for though.

Oh, the content? Didn't see that. Will fix it right away.

Fixed now in latest version 3.2.11. Thanks for reporting!

Thanks for the quick response!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ayozebarrera picture ayozebarrera  Â·  3Comments

webdream-fr picture webdream-fr  Â·  6Comments

simonbengtsson picture simonbengtsson  Â·  5Comments

JoakFlores picture JoakFlores  Â·  3Comments

bsparacino picture bsparacino  Â·  3Comments