[QRQC_2] No implicitAny in twenty-server (#12075)

# Introduction
Following https://github.com/twentyhq/twenty/pull/12068
Related with https://github.com/twentyhq/core-team-issues/issues/975

We're enabling `noImplicitAny` handled few use case manually, added a
`ts-expect-error` to the others, we should plan to handle them in the
future
This commit is contained in:
Paul Rastoin
2025-05-15 18:23:22 +02:00
committed by GitHub
parent 08ce2f831e
commit 442f8dbe3c
120 changed files with 331 additions and 50 deletions
@@ -260,12 +260,15 @@ export class QueryRunnerArgsFactory {
const overrideFilter = (filterObject: ObjectRecordFilter) => {
return Object.entries(filterObject).reduce((acc, [key, value]) => {
if (key === 'and' || key === 'or') {
// @ts-expect-error legacy noImplicitAny
acc[key] = value.map((nestedFilter: ObjectRecordFilter) =>
overrideFilter(nestedFilter),
);
} else if (key === 'not') {
// @ts-expect-error legacy noImplicitAny
acc[key] = overrideFilter(value);
} else {
// @ts-expect-error legacy noImplicitAny
acc[key] = this.transformFilterValueByType(
key,
value,
@@ -5,6 +5,7 @@ import {
} from 'src/engine/api/graphql/workspace-query-runner/utils/parse-result.util';
describe('handleSpecialKey', () => {
// @ts-expect-error legacy noImplicitAny
let result;
beforeEach(() => {
@@ -13,10 +14,12 @@ describe('handleSpecialKey', () => {
test('should correctly process a composite key and add it to the result object', () => {
handleCompositeKey(
// @ts-expect-error legacy noImplicitAny
result,
createCompositeFieldKey('complexField', 'link'),
'value1',
);
// @ts-expect-error legacy noImplicitAny
expect(result).toEqual({
complexField: {
link: 'value1',
@@ -26,15 +29,18 @@ describe('handleSpecialKey', () => {
test('should add values under the same newKey if called multiple times', () => {
handleCompositeKey(
// @ts-expect-error legacy noImplicitAny
result,
createCompositeFieldKey('complexField', 'link'),
'value1',
);
handleCompositeKey(
// @ts-expect-error legacy noImplicitAny
result,
createCompositeFieldKey('complexField', 'text'),
'value2',
);
// @ts-expect-error legacy noImplicitAny
expect(result).toEqual({
complexField: {
link: 'value1',
@@ -44,7 +50,9 @@ describe('handleSpecialKey', () => {
});
test('should not create a new field if the composite key is not correctly formed', () => {
// @ts-expect-error legacy noImplicitAny
handleCompositeKey(result, 'COMPOSITE___complexField', 'value1');
// @ts-expect-error legacy noImplicitAny
expect(result).toEqual({});
});
});
@@ -35,6 +35,7 @@ const pgGraphQLErrorMapping: PgGraphQLErrorMapping = {
'duplicate key value violates unique constraint': (command, objectName, _) =>
new WorkspaceQueryRunnerException(
`Cannot ${
// @ts-expect-error legacy noImplicitAny
pgGraphQLCommandMapping[command] ?? command
} ${objectName} because it violates a uniqueness constraint.`,
WorkspaceQueryRunnerExceptionCode.QUERY_VIOLATES_UNIQUE_CONSTRAINT,
@@ -42,6 +43,7 @@ const pgGraphQLErrorMapping: PgGraphQLErrorMapping = {
'violates foreign key constraint': (command, objectName, _) =>
new WorkspaceQueryRunnerException(
`Cannot ${
// @ts-expect-error legacy noImplicitAny
pgGraphQLCommandMapping[command] ?? command
} ${objectName} because it violates a foreign key constraint.`,
WorkspaceQueryRunnerExceptionCode.QUERY_VIOLATES_FOREIGN_KEY_CONSTRAINT,
@@ -110,11 +110,13 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
contextId,
);
// @ts-expect-error legacy noImplicitAny
return contextInstance[methodName].call(
contextInstance,
...executeParams,
);
} else {
// @ts-expect-error legacy noImplicitAny
return instance[methodName].call(instance, ...executeParams);
}
}
@@ -173,6 +175,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
contextId,
);
// @ts-expect-error legacy noImplicitAny
return contextInstance[methodName].call(
contextInstance,
executeParams[0],
@@ -180,6 +183,7 @@ export class WorkspaceQueryHookExplorer implements OnModuleInit {
transformedPayload,
);
} else {
// @ts-expect-error legacy noImplicitAny
return instance[methodName].call(
instance,
executeParams[0],