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)); 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) { if(operator) {
const operation = new operator({type: req.params.func, values: req.body}); const operation = new operator({type: req.params.func, values: req.body});
const validationResults = operation.validate(); const validationResults = operation.validate();

View File

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

View File

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