Fixed Typping for tsc

This commit is contained in:
Felix Kaspar 2023-11-21 14:40:29 +01:00
parent 3fb8c6c6eb
commit b9b7f0d5ea
3 changed files with 8 additions and 11 deletions

View File

@ -29,7 +29,7 @@ function handleEndpoint(req: Request, res: Response) {
pdfFiles = PdfFile.fromMulterFiles(Object.values(req.files).flatMap(va => va));
}
const operator: typeof Operator = getOperatorByName(req.params.func);
const operator = getOperatorByName(req.params.func);
if(operator) {
const operation = new operator({type: req.params.func, values: req.body});
const validationResults = operation.validate();

View File

@ -7,8 +7,8 @@ export const Operators = {
}
// TODO: Convert this to a map or similar
export function getOperatorByName(name: string): typeof Operator {
let foundClass: typeof Operator = null;
export function getOperatorByName(name: string): typeof Operator | undefined {
let foundClass: typeof Operator | undefined = undefined;
// Loop over each default export
Object.entries(Operators).some(([className, exportedClass]) => {
@ -27,5 +27,5 @@ export function getOperatorByName(name: string): typeof Operator {
export function listOperatorNames(): string[] {
// TODO: Implement this
return
return [];
}

View File

@ -18,15 +18,12 @@ export async function traverseOperations(operations: Action[], input: PdfFile[],
return results;
async function nextOperation(actions: Action[] | undefined, input: PdfFile[], progressCallback: (state: Progress) => void): Promise<void> {
console.log("Next Operation");
if(actions === undefined || (Array.isArray(actions) && actions.length == 0)) { // isEmpty
console.log("Last Operation");
if(Array.isArray(input)) {
console.log("ArrayOut: ", input);
if(!actions || (Array.isArray(actions) && actions.length == 0)) { // isEmpty
if(input && Array.isArray(input)) {
console.log("operation done: " + input[0].filename + (input.length > 1 ? "+" : ""));
results = results.concat(input);
return;
}
return;
}
for (let i = 0; i < actions.length; i++) {