refactor: Upgrade to TypeScript 5.5 (no-changelog) (#9828)

This commit is contained in:
Iván Ovejero 2024-06-24 17:49:59 +02:00 committed by GitHub
parent 1ba656ef4a
commit e33a47311f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 321 additions and 322 deletions

View file

@ -77,7 +77,7 @@
"semver": "^7.5.4",
"tslib": "^2.6.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.4.2",
"typescript": "^5.5.2",
"ws": ">=8.17.1"
},
"patchedDependencies": {

View file

@ -116,7 +116,7 @@ export class ExternalSecretsManager {
)
).map((i) => (i.status === 'rejected' ? null : i.value));
this.providers = Object.fromEntries(
(providers.filter((p) => p !== null) as SecretsProvider[]).map((s) => [s.name, s]),
providers.filter((p): p is SecretsProvider => p !== null).map((s) => [s.name, s]),
);
this.cachedSettings = settings;
await this.updateSecrets();

View file

@ -458,7 +458,7 @@ export class VaultProvider extends SecretsProvider {
)
)
.map((i) => (i.status === 'rejected' ? null : i.value))
.filter((v) => v !== null) as Array<[string, IDataObject]>,
.filter((v): v is [string, IDataObject] => v !== null),
);
const name = path.substring(0, path.length - 1);
return [name, data];
@ -480,7 +480,7 @@ export class VaultProvider extends SecretsProvider {
return [basePath.substring(0, basePath.length - 1), value[1]];
}),
)
).filter((v) => v !== null) as Array<[string, IDataObject]>,
).filter((v): v is [string, IDataObject] => v !== null),
);
this.cachedSecrets = secrets;
}

View file

@ -1047,10 +1047,8 @@ function getWorkflowHooksIntegrated(
const hookFunctions = hookFunctionsSave();
const preExecuteFunctions = hookFunctionsPreExecute();
for (const key of Object.keys(preExecuteFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
}
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
const hooks = hookFunctions[key] ?? [];
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
}
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData);
}
@ -1069,10 +1067,8 @@ export function getWorkflowHooksWorkerExecuter(
const hookFunctions = hookFunctionsSaveWorker();
const preExecuteFunctions = hookFunctionsPreExecute();
for (const key of Object.keys(preExecuteFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
}
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
const hooks = hookFunctions[key] ?? [];
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
}
return new WorkflowHooks(hookFunctions, mode, executionId, workflowData, optionalParameters);
@ -1139,18 +1135,14 @@ export function getWorkflowHooksMain(
const hookFunctions = hookFunctionsSave();
const pushFunctions = hookFunctionsPush();
for (const key of Object.keys(pushFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
}
hookFunctions[key]!.push.apply(hookFunctions[key], pushFunctions[key]);
const hooks = hookFunctions[key] ?? [];
hooks.push.apply(hookFunctions[key], pushFunctions[key]);
}
const preExecuteFunctions = hookFunctionsPreExecute();
for (const key of Object.keys(preExecuteFunctions)) {
if (hookFunctions[key] === undefined) {
hookFunctions[key] = [];
}
hookFunctions[key]!.push.apply(hookFunctions[key], preExecuteFunctions[key]);
const hooks = hookFunctions[key] ?? [];
hooks.push.apply(hookFunctions[key], preExecuteFunctions[key]);
}
if (!hookFunctions.nodeExecuteBefore) hookFunctions.nodeExecuteBefore = [];

View file

@ -737,8 +737,10 @@ export class ExecuteBatch extends BaseCommand {
return;
}
if (nodeEdgeCases[nodeName].capResults !== undefined) {
executionDataArray.splice(nodeEdgeCases[nodeName].capResults!);
const capResults = nodeEdgeCases[nodeName].capResults;
if (capResults !== undefined) {
executionDataArray.splice(capResults);
}
if (nodeEdgeCases[nodeName].ignoredProperties !== undefined) {

View file

@ -235,13 +235,14 @@ export class SourceControlExportService {
data: ICredentialDataDecryptedObject,
): ICredentialDataDecryptedObject => {
for (const [key] of Object.entries(data)) {
const value = data[key];
try {
if (data[key] === null) {
if (value === null) {
delete data[key]; // remove invalid null values
} else if (typeof data[key] === 'object') {
data[key] = this.replaceCredentialData(data[key] as ICredentialDataDecryptedObject);
} else if (typeof data[key] === 'string') {
data[key] = stringContainsExpression(data[key] as string) ? data[key] : '';
} else if (typeof value === 'object') {
data[key] = this.replaceCredentialData(value as ICredentialDataDecryptedObject);
} else if (typeof value === 'string') {
data[key] = stringContainsExpression(value) ? data[key] : '';
} else if (typeof data[key] === 'number') {
// TODO: leaving numbers in for now, but maybe we should remove them
continue;

View file

@ -84,8 +84,8 @@ export class SourceControlImportService {
}),
);
return remoteWorkflowFilesParsed.filter(
(e) => e !== undefined,
) as SourceControlWorkflowVersionId[];
(e): e is SourceControlWorkflowVersionId => e !== undefined,
);
}
public async getLocalVersionIdsFromDb(): Promise<SourceControlWorkflowVersionId[]> {

View file

@ -148,13 +148,15 @@ export class Telemetry {
properties.success ? 'success' : 'error'
}`;
if (!this.executionCountsBuffer[workflowId][key]) {
const executionTrackDataKey = this.executionCountsBuffer[workflowId][key];
if (!executionTrackDataKey) {
this.executionCountsBuffer[workflowId][key] = {
count: 1,
first: execTime,
};
} else {
this.executionCountsBuffer[workflowId][key]!.count++;
executionTrackDataKey.count++;
}
if (

View file

@ -85,6 +85,7 @@ export class ActiveWorkflows {
if (triggerResponse !== undefined) {
// If a response was given save it
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
this.activeWorkflows[workflowId].triggerResponses!.push(triggerResponse);
}
} catch (e) {
@ -105,6 +106,7 @@ export class ActiveWorkflows {
for (const pollNode of pollingNodes) {
try {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
this.activeWorkflows[workflowId].pollResponses!.push(
await this.activatePolling(
pollNode,

View file

@ -3679,7 +3679,7 @@ export function getExecuteFunctions(
});
}
return inputData[inputName][inputIndex] as INodeExecutionData[];
return inputData[inputName][inputIndex];
},
getInputSourceData: (inputIndex = 0, inputName = 'main') => {
if (executeData?.source === null) {

View file

@ -36,6 +36,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-plus-operands': 'warn',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
},
overrides: [

View file

@ -377,8 +377,10 @@ export function applyDeclarativeNodeOptionParameters(nodeType: INodeType): void
],
};
if (parameters[existingRequestOptionsIndex]?.options) {
parameters[existingRequestOptionsIndex].options!.sort((a, b) => {
const options = parameters[existingRequestOptionsIndex]?.options;
if (options) {
options.sort((a, b) => {
if ('displayName' in a && 'displayName' in b) {
if (a.displayName < b.displayName) {
return -1;

View file

@ -441,12 +441,8 @@ export class RoutingNode {
// Sort the returned options
const sortKey = action.properties.key;
inputData.sort((a, b) => {
const aSortValue = a.json[sortKey]
? (a.json[sortKey]?.toString().toLowerCase() as string)
: '';
const bSortValue = b.json[sortKey]
? (b.json[sortKey]?.toString().toLowerCase() as string)
: '';
const aSortValue = a.json[sortKey]?.toString().toLowerCase() ?? '';
const bSortValue = b.json[sortKey]?.toString().toLowerCase() ?? '';
if (aSortValue < bSortValue) {
return -1;
}

View file

@ -39,8 +39,9 @@ export class WorkflowHooks {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async executeHookFunctions(hookName: string, parameters: any[]) {
if (this.hookFunctions[hookName] !== undefined && Array.isArray(this.hookFunctions[hookName])) {
for (const hookFunction of this.hookFunctions[hookName]!) {
const hooks = this.hookFunctions[hookName];
if (hooks !== undefined && Array.isArray(hooks)) {
for (const hookFunction of hooks) {
await hookFunction.apply(this, parameters);
}
}

View file

@ -186,8 +186,8 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
}
test(t.expression, () => {
const evaluationTests = t.tests.filter(
(test) => test.type === 'evaluation',
) as ExpressionTestEvaluation[];
(test): test is ExpressionTestEvaluation => test.type === 'evaluation',
);
for (const test of evaluationTests) {
const input = test.input.map((d) => ({ json: d })) as any;
@ -209,8 +209,8 @@ for (const evaluator of ['tmpl', 'tournament'] as const) {
}
test(t.expression, () => {
for (const test of t.tests.filter(
(test) => test.type === 'transform',
) as ExpressionTestTransform[]) {
(test): test is ExpressionTestTransform => test.type === 'transform',
)) {
const expr = t.expression;
expect(extendSyntax(expr, test.forceTransform)).toEqual(test.result ?? expr);
}

File diff suppressed because it is too large Load diff