Skip to content

Commit

Permalink
chore: clean up Taxa TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkenny54 committed Feb 10, 2025
1 parent f03047e commit 25cde3c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export type TaxonData = TaxonomyData & {
taxon_name: string;
};

export type TaxonOverrides = {
status?: NativeStatusCode;
};

// Classes

export class BasePageRenderer {
Expand Down Expand Up @@ -104,6 +108,7 @@ export class Files {
targetFileName: string | undefined,
): Promise<Headers>;
static mkdir(dir: string): void;
static read(path: string): string;
static rmDir(dir: string): void;
static write(fileName: string, data: string, overwrite?: boolean): void;
}
Expand Down Expand Up @@ -188,11 +193,11 @@ export class Program {

export class Taxa<T> {
constructor(
inclusionList: Record<string, TaxonData> | true,
inclusionList: Record<string, TaxonOverrides> | true,
errorLog: ErrorLog,
showFlowerErrors: boolean,
taxonFactory?: (td: TaxonData, g: Genera) => T,
extraTaxa?: TaxonData[],
extraTaxa?: TaxonOverrides[],
extraSynonyms?: Record<string, string>[],
);
getTaxon(name: string): T;
Expand Down
8 changes: 4 additions & 4 deletions lib/taxonomy/taxa.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Taxa {
#isSubset;

/**
* @param {Object<string,import("../index.js").TaxonData>|true} inclusionList
* @param {Object<string,import("../index.js").TaxonOverrides>|true} inclusionList
* @param {ErrorLog} errorLog
* @param {boolean} showFlowerErrors
* @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory
Expand Down Expand Up @@ -224,7 +224,7 @@ class Taxa {

/**
* @param {SynonymData[]} synCSV
* @param {Object<string,import("../index.js").TaxonData>|boolean} inclusionList
* @param {Object<string,import("../index.js").TaxonOverrides>|boolean} inclusionList
*/
#loadSyns(synCSV, inclusionList) {
for (const syn of synCSV) {
Expand All @@ -246,7 +246,7 @@ class Taxa {

/**
* @param {import("../index.js").TaxonData[]} taxaCSV
* @param {Object<string,import("../index.js").TaxonData>|true} inclusionList
* @param {Object<string,import("../index.js").TaxonOverrides>|true} inclusionList
* @param {function(import("../index.js").TaxonData,Genera):Taxon} taxonFactory
* @param {Genera} genera
* @param {boolean} showFlowerErrors
Expand All @@ -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];
Expand Down

0 comments on commit 25cde3c

Please sign in to comment.