fix(workflow): remove a few ts-ignore and eslint-disable (#3958)

fix(workflow): remove a few `ts-ignore` and `eslint-disable`. improve typing
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2022-09-09 16:34:50 +02:00
committed by GitHub
parent 712924cbc3
commit a73ac1d94f
9 changed files with 72 additions and 83 deletions

View File

@@ -76,9 +76,8 @@ export abstract class ExecutionBaseError extends Error {
this.message = error.message as string;
}
if (Object.prototype.hasOwnProperty.call(error, 'context')) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.context = (error as any).context;
if (error instanceof ExecutionBaseError) {
this.context = error.context;
}
}
}
@@ -130,14 +129,12 @@ abstract class NodeError extends ExecutionBaseError {
): string | null {
// eslint-disable-next-line no-restricted-syntax
for (const key of potentialKeys) {
if (error[key]) {
if (typeof error[key] === 'string') return error[key] as string;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
if (typeof error[key] === 'number') return error[key]!.toString();
if (Array.isArray(error[key])) {
// @ts-ignore
const resolvedErrors: string[] = error[key]
// @ts-ignore
const value = error[key];
if (value) {
if (typeof value === 'string') return value;
if (typeof value === 'number') return value.toString();
if (Array.isArray(value)) {
const resolvedErrors: string[] = value
.map((error) => {
if (typeof error === 'string') return error;
if (typeof error === 'number') return error.toString();
@@ -146,15 +143,15 @@ abstract class NodeError extends ExecutionBaseError {
}
return null;
})
.filter((errorValue: string | null) => errorValue !== null);
.filter((errorValue): errorValue is string => errorValue !== null);
if (resolvedErrors.length === 0) {
return null;
}
return resolvedErrors.join(' | ');
}
if (this.isTraversableObject(error[key])) {
const property = this.findProperty(error[key] as JsonObject, potentialKeys);
if (this.isTraversableObject(value)) {
const property = this.findProperty(value, potentialKeys);
if (property) {
return property;
}
@@ -164,8 +161,9 @@ abstract class NodeError extends ExecutionBaseError {
// eslint-disable-next-line no-restricted-syntax
for (const key of traversalKeys) {
if (this.isTraversableObject(error[key])) {
const property = this.findProperty(error[key] as JsonObject, potentialKeys, traversalKeys);
const value = error[key];
if (this.isTraversableObject(value)) {
const property = this.findProperty(value, potentialKeys, traversalKeys);
if (property) {
return property;
}