refactor(core): clear @ts-ignore from workflow and core packages (#4467)

* 📘 Clear all `@ts-ignore` comments from workflow package

* 👕 Default to error with package-level overrides

* refactor(core): clear all `@ts-ignore` comments from core package (#4473)

👕 Clear all `@ts-ignore` comments from core package

* ✏️ Update comment
This commit is contained in:
Iván Ovejero
2022-10-31 12:45:34 +01:00
committed by GitHub
parent 46905fd2cb
commit ec5ef0c50d
15 changed files with 87 additions and 62 deletions

View File

@@ -16,6 +16,7 @@ import {
IN8nRequestOperations,
INodeCredentialDescription,
IExecuteData,
INodeTypeDescription,
} from '../src';
import * as Helpers from './Helpers';
@@ -1689,8 +1690,7 @@ describe('RoutingNode', () => {
connections: {},
};
// @ts-ignore
nodeType.description = { ...testData.input.nodeType };
nodeType.description = { ...testData.input.nodeType } as INodeTypeDescription;
const workflow = new Workflow({
nodes: workflowData.nodes,
@@ -1714,8 +1714,7 @@ describe('RoutingNode', () => {
source: null,
} as IExecuteData;
// @ts-ignore
const nodeExecuteFunctions: INodeExecuteFunctions = {
const nodeExecuteFunctions: Partial<INodeExecuteFunctions> = {
getExecuteFunctions: () => {
return Helpers.getExecuteFunctions(
workflow,
@@ -1751,7 +1750,7 @@ describe('RoutingNode', () => {
runIndex,
nodeType,
executeData,
nodeExecuteFunctions,
nodeExecuteFunctions as INodeExecuteFunctions,
);
expect(result).toEqual(testData.output);
@@ -1763,12 +1762,7 @@ describe('RoutingNode', () => {
const tests: Array<{
description: string;
input: {
nodeType: {
properties?: INodeProperties[];
credentials?: INodeCredentialDescription[];
requestDefaults?: IHttpRequestOptions;
requestOperations?: IN8nRequestOperations;
};
nodeType: Partial<INodeTypeDescription>;
node: {
parameters: INodeParameters;
};
@@ -1868,8 +1862,7 @@ describe('RoutingNode', () => {
connections: {},
};
// @ts-ignore
nodeType.description = { ...testData.input.nodeType };
nodeType.description = { ...testData.input.nodeType } as INodeTypeDescription;
const workflow = new Workflow({
nodes: workflowData.nodes,
@@ -1895,8 +1888,7 @@ describe('RoutingNode', () => {
let currentItemIndex = 0;
for (let iteration = 0; iteration < inputData.main[0]!.length; iteration++) {
// @ts-ignore
const nodeExecuteFunctions: INodeExecuteFunctions = {
const nodeExecuteFunctions: Partial<INodeExecuteFunctions> = {
getExecuteFunctions: () => {
return Helpers.getExecuteFunctions(
workflow,
@@ -1927,6 +1919,10 @@ describe('RoutingNode', () => {
},
};
if (!nodeExecuteFunctions.getExecuteSingleFunctions) {
fail('Expected nodeExecuteFunctions to contain getExecuteSingleFunctions');
}
const routingNodeExecutionContext = nodeExecuteFunctions.getExecuteSingleFunctions(
routingNode.workflow,
routingNode.runExecutionData,

View File

@@ -1,9 +1,12 @@
import {
IBinaryKeyData,
IConnections,
IDataObject,
INode,
INodeExecutionData,
INodeParameters,
IRunExecutionData,
NodeParameterValueType,
Workflow,
} from '../src';
@@ -696,7 +699,17 @@ describe('Workflow', () => {
});
describe('getParameterValue', () => {
const tests = [
const tests: {
description: string;
input: {
[nodeName: string]: {
parameters: Record<string, NodeParameterValueType>;
outputJson?: IDataObject;
outputBinary?: IBinaryKeyData;
};
};
output: Record<string, unknown>;
}[] = [
{
description: 'read simple not expression value',
input: {
@@ -881,6 +894,7 @@ describe('Workflow', () => {
binaryKey: {
data: '',
type: '',
mimeType: 'test',
fileName: 'test-file1.jpg',
},
},
@@ -908,6 +922,7 @@ describe('Workflow', () => {
binaryKey: {
data: '',
type: '',
mimeType: 'test',
fileName: 'test-file1.jpg',
},
},
@@ -1134,8 +1149,7 @@ describe('Workflow', () => {
{
name: 'Node3',
parameters: testData.input.hasOwnProperty('Node3')
? // @ts-ignore
testData.input.Node3.parameters
? testData.input.Node3?.parameters
: {},
type: 'test.set',
typeVersion: 1,
@@ -1145,8 +1159,7 @@ describe('Workflow', () => {
{
name: 'Node 4 with spaces',
parameters: testData.input.hasOwnProperty('Node4')
? // @ts-ignore
testData.input.Node4.parameters
? testData.input.Node4.parameters
: {},
type: 'test.set',
typeVersion: 1,
@@ -1187,6 +1200,11 @@ describe('Workflow', () => {
runData: {
Node1: [
{
source: [
{
previousNode: 'test',
},
],
startTime: 1,
executionTime: 1,
data: {
@@ -1194,7 +1212,6 @@ describe('Workflow', () => {
[
{
json: testData.input.Node1.outputJson || testData.input.Node1.parameters,
// @ts-ignore
binary: testData.input.Node1.outputBinary,
},
],
@@ -1226,7 +1243,6 @@ describe('Workflow', () => {
timezone,
{},
);
// @ts-ignore
expect(result).toEqual(testData.output[parameterName]);
}
});
@@ -1278,7 +1294,6 @@ describe('Workflow', () => {
// const workflow = new Workflow({ nodes, connections, active: false, nodeTypes });
// const activeNodeName = 'Node2';
// // @ts-ignore
// const parameterValue = nodes.find((node) => node.name === activeNodeName).parameters.name;
// // const parameterValue = '=[data.propertyName]'; // TODO: Make this dynamic from node-data via "activeNodeName"!
// const runData: RunData = {