From 005aac7df199029dcf6557dc5f6b5219f65f9b7c Mon Sep 17 00:00:00 2001 From: Charlie Kolb Date: Fri, 29 Nov 2024 13:03:39 +0100 Subject: [PATCH] Add more fixes --- packages/cli/src/services/curl.service.ts | 16 ++++++++------- .../middlewares/body-parser.test.ts | 8 ++++---- .../test/integration/shared/db/credentials.ts | 5 +++-- packages/core/src/WorkflowExecute.ts | 6 ------ .../src/components/MfaSetupModal.vue | 1 - .../editor-ui/src/components/NodeSettings.vue | 6 ++++-- .../executions/ExecutionsFilter.vue | 5 ++--- .../global/GlobalExecutionsListItem.vue | 20 ++++++++++--------- .../src/composables/useHistoryHelper.test.ts | 10 +++++----- .../src/composables/useWorkflowHelpers.ts | 14 ++++++------- .../src/stores/pushConnection.store.ts | 3 ++- .../editor-ui/src/stores/workflows.store.ts | 2 +- 12 files changed, 48 insertions(+), 48 deletions(-) diff --git a/packages/cli/src/services/curl.service.ts b/packages/cli/src/services/curl.service.ts index 8875fd9828..21f009b8ce 100644 --- a/packages/cli/src/services/curl.service.ts +++ b/packages/cli/src/services/curl.service.ts @@ -261,12 +261,12 @@ const mapCookies = (cookies: CurlJson['cookies']): { cookie: string } | {} => { }; export const flattenObject = (obj: { [x: string]: any }, prefix = '') => - Object.keys(obj).reduce((acc, k) => { + Object.keys(obj).reduce>((acc, k) => { const pre = prefix.length ? prefix + '.' : ''; - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k)); - //@ts-ignore - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + // @Problem: `typeof null` is `object`, which creates a bug here + if (typeof obj[k] === 'object') + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + Object.assign(acc, flattenObject(obj[k], pre + k)); else acc[pre + k] = obj[k]; return acc; }, {}); @@ -465,12 +465,14 @@ export class CurlService { } if (!Object.keys(httpNodeParameters.options?.redirect.redirect).length) { - // @ts-ignore + // @Cleanup: Type `options.redirect` as optional and fix type errors + // @ts-expect-error Options is typed as non-optional delete httpNodeParameters.options.redirect; } if (!Object.keys(httpNodeParameters.options.response.response).length) { - // @ts-ignore + // @Cleanup: Type `options.response` as optional and fix type errors + // @ts-expect-error Options is typed as non-optional delete httpNodeParameters.options.response; } diff --git a/packages/cli/test/integration/middlewares/body-parser.test.ts b/packages/cli/test/integration/middlewares/body-parser.test.ts index a3381fe9e8..ca6ccf029f 100644 --- a/packages/cli/test/integration/middlewares/body-parser.test.ts +++ b/packages/cli/test/integration/middlewares/body-parser.test.ts @@ -21,8 +21,8 @@ describe('bodyParser', () => { const response = await request(server) .post('/') .set('content-encoding', 'gzip') - // @ts-ignore - .serialize((d) => gzipSync(JSON.stringify(d))) + // Mock for testing + .serialize((d) => gzipSync(JSON.stringify(d)) as unknown as string) .send({ hello: 'world' }) .expect(200); expect(response.text).toEqual('{"hello":"world"}'); @@ -32,8 +32,8 @@ describe('bodyParser', () => { const response = await request(server) .post('/') .set('content-encoding', 'deflate') - // @ts-ignore - .serialize((d) => deflateSync(JSON.stringify(d))) + // Mock for testing + .serialize((d) => deflateSync(JSON.stringify(d)) as unknown as string) .send({ hello: 'world' }) .expect(200); expect(response.text).toEqual('{"hello":"world"}'); diff --git a/packages/cli/test/integration/shared/db/credentials.ts b/packages/cli/test/integration/shared/db/credentials.ts index 5593b7d55a..c0383ed703 100644 --- a/packages/cli/test/integration/shared/db/credentials.ts +++ b/packages/cli/test/integration/shared/db/credentials.ts @@ -1,3 +1,4 @@ +import type { ICredentialDataDecryptedObject } from 'n8n-workflow'; import { Container } from 'typedi'; import { CredentialsEntity } from '@/databases/entities/credentials-entity'; @@ -17,8 +18,8 @@ export async function encryptCredentialData( const { createCredentialsFromCredentialsEntity } = await import('@/credentials-helper'); const coreCredential = createCredentialsFromCredentialsEntity(credential, true); - // @ts-ignore - coreCredential.setData(credential.data); + // data column is actually an object despite the type + coreCredential.setData(credential.data as unknown as ICredentialDataDecryptedObject); return Object.assign(credential, coreCredential.getDataToSave()); } diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 07819a7102..640336a1af 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -1504,17 +1504,11 @@ export class WorkflowExecute { lineResult.json.$error !== undefined && lineResult.json.$json !== undefined ) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore lineResult.error = lineResult.json.$error as NodeApiError | NodeOperationError; lineResult.json = { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore error: (lineResult.json.$error as NodeApiError | NodeOperationError).message, }; } else if (lineResult.error !== undefined) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore lineResult.json = { error: lineResult.error.message }; } } diff --git a/packages/editor-ui/src/components/MfaSetupModal.vue b/packages/editor-ui/src/components/MfaSetupModal.vue index 9f292124c3..5a3dea2ac3 100644 --- a/packages/editor-ui/src/components/MfaSetupModal.vue +++ b/packages/editor-ui/src/components/MfaSetupModal.vue @@ -9,7 +9,6 @@ import { ref, onMounted } from 'vue'; import { useUsersStore } from '@/stores/users.store'; import { mfaEventBus } from '@/event-bus'; import { useToast } from '@/composables/useToast'; -//@ts-ignore import QrcodeVue from 'qrcode.vue'; import { useClipboard } from '@/composables/useClipboard'; import { useI18n } from '@/composables/useI18n'; diff --git a/packages/editor-ui/src/components/NodeSettings.vue b/packages/editor-ui/src/components/NodeSettings.vue index 5256f41983..b53a44c979 100644 --- a/packages/editor-ui/src/components/NodeSettings.vue +++ b/packages/editor-ui/src/components/NodeSettings.vue @@ -403,7 +403,8 @@ const valueChanged = (parameterData: IUpdateInformation) => { if (parameterData.value && typeof parameterData.value === 'object') { for (const parameterName of Object.keys(parameterData.value)) { - //@ts-ignore + // @Cleanup: Instead use `Object.entries()` to get both key and value + // @ts-expect-error this breaks the connection of keys and values newValue = parameterData.value[parameterName]; // Remove the 'parameters.' from the beginning to just have the @@ -415,7 +416,8 @@ const valueChanged = (parameterData: IUpdateInformation) => { const parameterPathArray = parameterPath.match(/(.*)\[(\d+)\]$/); // Apply the new value - //@ts-ignore + // @Problem: `parameterData[parameterName]` makes little sense to me, please investigate if this should be `parameterData.value[parameterName]`? But that doesn't really make sense either. + // @ts-expect-error This seems like a bug? if (parameterData[parameterName] === undefined && parameterPathArray !== null) { // Delete array item const path = parameterPathArray[1]; diff --git a/packages/editor-ui/src/components/executions/ExecutionsFilter.vue b/packages/editor-ui/src/components/executions/ExecutionsFilter.vue index 4325c9b94f..164cc154c8 100644 --- a/packages/editor-ui/src/components/executions/ExecutionsFilter.vue +++ b/packages/editor-ui/src/components/executions/ExecutionsFilter.vue @@ -70,9 +70,8 @@ const vModel = reactive( return filter[key]; }, set(value) { - // TODO: find out what exactly is typechecker complaining about - - // @ts-ignore + // @Cleanup: Type the `computed<>()` call correctly or swap reduce for an easier to type solution + // @ts-expect-error We lose type info on value because we set this up in a reduce loop filter[key] = value; emit('filterChanged', filter); }, diff --git a/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue b/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue index 1fbbfd542a..f40c663f1d 100644 --- a/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue +++ b/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue @@ -11,13 +11,14 @@ import type { PermissionsRecord } from '@/permissions'; type Command = 'retrySaved' | 'retryOriginal' | 'delete'; -const emit = defineEmits<{ - stop: [data: ExecutionSummary]; - select: [data: ExecutionSummary]; - retrySaved: [data: ExecutionSummary]; - retryOriginal: [data: ExecutionSummary]; - delete: [data: ExecutionSummary]; -}>(); +const emit = defineEmits< + { + stop: [data: ExecutionSummary]; + select: [data: ExecutionSummary]; + } & { + [c in Command]: [data: ExecutionSummary]; + } +>(); const props = withDefaults( defineProps<{ @@ -160,8 +161,9 @@ function onSelect() { } async function handleActionItemClick(commandData: Command) { - //@ts-ignore todo: fix this type - emit(commandData, props.execution); + // The `emit` function is not typed very well and does not take type unions of the single event types + // Se we need to hide the type + emit(commandData as never, props.execution); }