aanckar / react-pdf-tailwind

Use Tailwind CSS to style PDFs created with react-pdf
315 stars 11 forks source link

`tsc` fails due to missing Node/DOM library #9

Closed chrissantamaria closed 1 year ago

chrissantamaria commented 1 year ago

When trying to build the library locally or explicitly run tsc, a type error is reported:

pnpm tsc
src/index.ts:367:11 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

367           console.warn(`Property ${property} does not support negative values`);
              ~~~~~~~

Found 1 error in src/index.ts:367

This makes sense, as the type definitions for console would have to come from a platform-specific library. Some options I see are:

  1. use Node bindings by adding @types/node (as I've done on my fork)
  2. use DOM bindings by adding DOM to compilerOptions.lib in tsconfig.json
  3. manually // @ts-expect-error (not ideal)

imo option 1 seems the easiest, though it does implicitly suggest that this library should be used primarily in a Node context rather than web (which afaik it technically should)

Happy to open a PR with whatever approach makes the most sense :)

chrissantamaria commented 1 year ago

Ah, looks like my local repo was outdated and didn't realize the console.warn was removed in #7 - disregard!