Skip to content

Commit d8becdf

Browse files
actions-userclaude
andcommitted
fix(invoice): resolve pdfmake TypeScript build errors for @types/pdfmake@0.3.2
- Remove .default reference (module uses named exports, not default export) - Capture pdfmake module directly instead of destructuring .default - Cast table body as TableCell[][] to satisfy ForbidOtherElementProperties constraint - Add typeof vfs !== 'string' guard to narrow vfs type correctly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 14dab55 commit d8becdf

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

src/components/invoice/invoice-pdf.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { TDocumentDefinitions } from 'pdfmake/interfaces'
1+
import type { TableCell, TDocumentDefinitions } from 'pdfmake/interfaces'
22

33
import { invoiceData } from './data'
44

@@ -9,12 +9,12 @@ const TEXT_COLOR = '#2a2a2a'
99
const MUTED_COLOR = '#666666'
1010
const BORDER_COLOR = '#e5e5e5'
1111

12-
let pdfMakePromise: Promise<typeof import('pdfmake/build/pdfmake').default> | null = null
12+
let pdfMakePromise: Promise<typeof import('pdfmake/build/pdfmake')> | null = null
1313

1414
async function loadPdfMake() {
1515
if (!pdfMakePromise) {
1616
pdfMakePromise = (async () => {
17-
const [{ default: pdfMake }, fontsModule] = await Promise.all([
17+
const [pdfMake, fontsModule] = await Promise.all([
1818
import('pdfmake/build/pdfmake'),
1919
import('pdfmake/build/vfs_fonts'),
2020
])
@@ -45,7 +45,7 @@ async function loadPdfMake() {
4545
: undefined) ??
4646
(isFontDictionary(fontsDefault) ? fontsDefault : undefined)
4747

48-
if (vfs) {
48+
if (vfs && typeof vfs !== 'string') {
4949
;(pdfMake as unknown as { vfs: Record<string, string> }).vfs = vfs
5050
}
5151

@@ -76,12 +76,7 @@ function buildDocDefinition(data: InvoiceData): TDocumentDefinitions {
7676
{},
7777
{ text: `$${data.totalPaid}` },
7878
],
79-
[
80-
{ text: 'Late Fees', colSpan: 3, alignment: 'right', bold: true, color: '#555555' },
81-
{},
82-
{},
83-
{ text: '$0.00' },
84-
],
79+
[{ text: 'Late Fees', colSpan: 3, alignment: 'right', bold: true, color: '#555555' }, {}, {}, { text: '$0.00' }],
8580
[
8681
{ text: 'Remaining Balance', colSpan: 3, alignment: 'right', bold: true, color: '#555555' },
8782
{},
@@ -167,7 +162,7 @@ function buildDocDefinition(data: InvoiceData): TDocumentDefinitions {
167162
table: {
168163
headerRows: 1,
169164
widths: ['*', 70, 50, 70],
170-
body: [
165+
body: ([
171166
[
172167
{ text: 'Description', style: 'tableHeader' },
173168
{ text: 'Price', style: 'tableHeader' },
@@ -176,7 +171,7 @@ function buildDocDefinition(data: InvoiceData): TDocumentDefinitions {
176171
],
177172
...lineItemRows,
178173
...totalsRows,
179-
],
174+
] as TableCell[][]),
180175
},
181176
layout: {
182177
hLineColor: () => BORDER_COLOR,

0 commit comments

Comments
 (0)