cboulanger / zotero-sync-bookends

Bookends Store for https://github.com/retorquere/zotero-sync
7 stars 0 forks source link

Errors: 'e' is of type 'unknown' & Type 'unknown' is not assignable to type 'string | null' #3

Open joshuawagner opened 1 year ago

joshuawagner commented 1 year ago

Hi, I'm almost done with my dissertation! Thanks for your help over the years. Do you have a patreon or paypal so I can send a little appreciation your way?

I'm trying to get zotero-sync-bookends up and running again on my M1 mac after a while. I don't know what happened to my previous setup because the api key and bookends db name were both at default in my local repo. Anyways...starting over.

What I've done so far

reading through the readme and following instructions**

created a new key in Zotero portal online

The following links are accessible:

edited lines 29 and 30 in /Users/josh/node_modules/@cboulanger/zotero-sync-bookends/test.ts

install node packages

run!

Errors

I get 6 errors from /src/index.ts.

> @cboulanger/zotero-sync-bookends@2.1.1 test
> tsc && npx ts-node test.ts

src/index.ts:105:7 - error TS18046: 'e' is of type 'unknown'.

105       e.lastJxaCmd = cmd;
          ~

src/index.ts:162:11 - error TS18046: 'e' is of type 'unknown'.

162       if (e.message.includes("-1728")) {
              ~

src/index.ts:313:11 - error TS18046: 'e' is of type 'unknown'.

313       if (e.message.includes("-1728")) {
              ~

src/index.ts:329:11 - error TS18046: 'e' is of type 'unknown'.

329       if (e.message.includes("-1728")) {
              ~

src/index.ts:378:17 - error TS18046: 'e' is of type 'unknown'.

378             if (e.message.includes("-1712")) {
                    ~

src/index.ts:380:15 - error TS2322: Type 'unknown' is not assignable to type 'string | null'.

380               error = e;
                  ~~~~~

Found 6 errors in the same file, starting at: src/index.ts:105

Index.ts

Here's the section of index.ts that I think it's referencing in the error: https://github.com/cboulanger/zotero-sync-bookends/blob/fea145e32ca1961bf226fc82b5c0b25ecf35a84f/src/index.ts#L349-L398

cboulanger commented 1 year ago

Hi Joshua - I quickly want to respond to let you know I've seen the issue - I'm a bit short on time at the moment but I hope I can be of help. My gut feeling is that it is a compatibility issue - I haven't updated the code in such a long time that it might no longer work with current node or jsx versions. I'l have to try it myself and will do that as soon as I find a minute.

In the meantime, can you tell me what NodeJS and Mac versions you are working on?

Thanks for your offer - I just setting up GitHub Sponsors (not active yet) and maybe that's a way, otherwise I am happy to give you my paypal address.

joshuawagner commented 1 year ago

Sure, paypal is great.

I'm on MacOS 13.4.1 on an M1. I was on NodeJS 18.9.0 but I updated to the 18.6.1 (LTS) and I get the same errors.

cboulanger commented 1 year ago

Thanks - I hope I can have a look tonight. I've enabled GitHub Sponsoring, if that works for you, or my PayPal is c.boulanger@gmx.de ... Very much appreciated!

cboulanger commented 1 year ago

I tried it with v18.16.1 and v20.3.1 (the latest versions of v18 and v20 as provided by nvm) and both worked. I am on MacOS 13.2.1 (Intel) I wonder if Apple Silicon might be a problem. Do you have an older Mac to try it on?

cboulanger commented 1 year ago

And maybe as a workaround, adapt line 378 like so:

if (e && e.message && e.message.includes("-1712")) { 

Does this help?

joshuawagner commented 1 year ago

When I enter that change VS Code gives me as a tooltip: 20230721_062119-screenshot

These are the errors that I get when I npm test

src/index.ts:105:7 - error TS18046: 'e' is of type 'unknown'.

105       e.lastJxaCmd = cmd;
          ~

src/index.ts:162:11 - error TS18046: 'e' is of type 'unknown'.

162       if (e.message.includes("-1728")) {
              ~

src/index.ts:313:11 - error TS18046: 'e' is of type 'unknown'.

313       if (e.message.includes("-1728")) {
              ~

src/index.ts:329:11 - error TS18046: 'e' is of type 'unknown'.

329       if (e.message.includes("-1728")) {
              ~

src/index.ts:378:24 - error TS2339: Property 'message' does not exist on type '{}'.

378             if (e && e.message && e.message.includes("-1712")) {
                           ~~~~~~~

src/index.ts:378:37 - error TS2339: Property 'message' does not exist on type '{}'.

378             if (e && e.message && e.message.includes("-1712")) {
                                        ~~~~~~~

src/index.ts:380:15 - error TS2322: Type '{}' is not assignable to type 'string'.

380               error = e;
                  ~~~~~

Here are the error indicators. 20230721_062139-screenshot

I'll start from the top: 20230721_062709-screenshot

20230721_063730-screenshot

20230721_062905-screenshot

20230721_062953-screenshot

20230721_063100-screenshot

20230721_063133-screenshot