[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:
+3
@@ -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,
|
||||
|
||||
+8
@@ -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({});
|
||||
});
|
||||
});
|
||||
|
||||
+2
@@ -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,
|
||||
|
||||
+4
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user