Skip to content

Commit

Permalink
chore: fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanChain committed Jan 11, 2025
1 parent 89372a0 commit ff5f33b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function onShutdown(): void {
addon.data.dialog?.window?.close();
// Remove addon object
addon.data.alive = false;
// @ts-ignore - Plugin instance is not typed
delete Zotero[config.addonInstance];
}

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import Addon from "./addon";
import { config } from "../package.json";

const basicTool = new BasicTool();

// @ts-ignore - Plugin instance is not typed
if (!basicTool.getGlobal("Zotero")[config.addonInstance]) {
_globalThis.addon = new Addon();
defineGlobal("ztoolkit", () => {
return _globalThis.addon.data.ztoolkit;
});
// @ts-ignore - Plugin instance is not typed
Zotero[config.addonInstance] = addon;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/arxiv-merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class arXivMerge {
const preprintItem = items.find((item) => item.itemType === "preprint");
const publishedItem = items.find((item) =>
(
["journalArticle", "conferencePaper"] as Zotero.Item.ItemType[]
["journalArticle", "conferencePaper"] as _ZoteroTypes.Item.ItemType[]
).includes(item.itemType),
);
return { preprintItem, publishedItem };
Expand Down
3 changes: 3 additions & 0 deletions src/modules/arxiv-update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ async function createItemByZotero(
): Promise<Zotero.Item | false> {
let translate;
if (paper.doi) {
// @ts-ignore - Translate is not typed
translate = new Zotero.Translate.Search();
translate.setIdentifier({ DOI: paper.doi });
const translators = await translate.getTranslators();
translate.setTranslator(translators);
} else if (paper.url) {
// @ts-ignore - Translate is not typed
translate = new Zotero.Translate.Web();
const doc = await Zotero.HTTP.processDocuments(paper.url, (doc) => doc);
translate.setDocument(doc[0]);
Expand Down Expand Up @@ -274,6 +276,7 @@ class PaperFinder {
for (const attachmentID of this.item.getAttachments()) {
const attachment = await Zotero.Items.getAsync(attachmentID);
if (!attachment.isPDFAttachment()) continue;
// @ts-ignore - PDFWorker is not typed
const fullText = await Zotero.PDFWorker.getFullText(attachmentID, 1);
const match = fullText.text.match(/arXiv:[\d.]+v(\d+)/);
if (!match) continue;
Expand Down

0 comments on commit ff5f33b

Please sign in to comment.