2

I'm trying to use printJS in Angular, and it was Ok until I had to use the multiple images feature. I was getting a error of printJS is not defined, and after searching for solution for the import I got here: https://github.com/crabbly/Print.js/issues/154.

Tried the solution of import. But now I have this problem with the initialization of printJS

What I'm trying to do:

//import
import printJSer from 'print-js'
...
// create a list first with the URLs
listImpressao.push(fileURL)
...
// try to print all images
if(tipo=='image'){
   printJSer({printable: listImpressao, type:'image'})
}

It gives the following error:

error TS2345: Argument of type '{ printable: string[]; type: string; }' is not assignable to parameter of type 'string | Configuration'. Type '{ printable: string[]; type: string; }' is not assignable to type 'Configuration'. Types of property 'printable' are incompatible. Type 'string[]' is not assignable to type 'string'.

What I need to do to stop this error? I can't ng build the app because of this error.

R. Richards
  • 24,603
  • 10
  • 64
  • 64

1 Answers1

1

The library latest version has an updated TypeScript interface. https://github.com/crabbly/Print.js/commit/3a3c60422a184560c07715eed0ee8d70f36ea393

The printable parameter can now be a string or array.

Just run npm update print-js and you should no longer get that error.

crabbly
  • 5,106
  • 1
  • 23
  • 46