From 25cde3c80b1e94bf43d41820c00e5e353eaaf376 Mon Sep 17 00:00:00 2001 From: John Kenny Date: Mon, 10 Feb 2025 08:08:37 -0800 Subject: [PATCH] chore: clean up Taxa TypeScript --- lib/index.d.ts | 9 +++++++-- lib/taxonomy/taxa.js | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/index.d.ts b/lib/index.d.ts index c78dd80..0d66cf4 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -46,6 +46,10 @@ export type TaxonData = TaxonomyData & { taxon_name: string; }; +export type TaxonOverrides = { + status?: NativeStatusCode; +}; + // Classes export class BasePageRenderer { @@ -104,6 +108,7 @@ export class Files { targetFileName: string | undefined, ): Promise; static mkdir(dir: string): void; + static read(path: string): string; static rmDir(dir: string): void; static write(fileName: string, data: string, overwrite?: boolean): void; } @@ -188,11 +193,11 @@ export class Program { export class Taxa { constructor( - inclusionList: Record | true, + inclusionList: Record | true, errorLog: ErrorLog, showFlowerErrors: boolean, taxonFactory?: (td: TaxonData, g: Genera) => T, - extraTaxa?: TaxonData[], + extraTaxa?: TaxonOverrides[], extraSynonyms?: Record[], ); getTaxon(name: string): T; diff --git a/lib/taxonomy/taxa.js b/lib/taxonomy/taxa.js index 5c75c0e..6c8530e 100644 --- a/lib/taxonomy/taxa.js +++ b/lib/taxonomy/taxa.js @@ -40,7 +40,7 @@ class Taxa { #isSubset; /** - * @param {Object|true} inclusionList + * @param {Object|true} inclusionList * @param {ErrorLog} errorLog * @param {boolean} showFlowerErrors * @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory @@ -224,7 +224,7 @@ class Taxa { /** * @param {SynonymData[]} synCSV - * @param {Object|boolean} inclusionList + * @param {Object|boolean} inclusionList */ #loadSyns(synCSV, inclusionList) { for (const syn of synCSV) { @@ -246,7 +246,7 @@ class Taxa { /** * @param {import("../index.js").TaxonData[]} taxaCSV - * @param {Object|true} inclusionList + * @param {Object|true} inclusionList * @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory * @param {Genera} genera * @param {boolean} showFlowerErrors @@ -255,7 +255,7 @@ class Taxa { for (const row of taxaCSV) { const name = row["taxon_name"]; - /** @type {import("../index.js").TaxonData|{status?:import("../index.js").NativeStatusCode}} */ + /** @type {import("../index.js").TaxonOverrides} */ let taxon_overrides = {}; if (inclusionList !== true) { taxon_overrides = inclusionList[name];