[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

View File

@ -16,7 +16,9 @@ const generateRandomAmountMicros = () => {
return firstDigit * 10000000000;
};
// @ts-expect-error legacy noImplicitAny
const generateOpportunities = (companies) => {
// @ts-expect-error legacy noImplicitAny
return companies.map((company) => ({
id: v4(),
name: company.name,
@ -66,6 +68,7 @@ export const seedOpportunityWithDemoData = async (
])
.orIgnore()
.values(
// @ts-expect-error legacy noImplicitAny
opportunities.map((opportunity, index) => ({
...opportunity,
position: index,

View File

@ -16,9 +16,11 @@ export const seedWorkspaceWithDemoData = async (
objectMetadata: ObjectMetadataEntity[],
) => {
const objectMetadataMap = objectMetadata.reduce((acc, object) => {
// @ts-expect-error legacy noImplicitAny
acc[object.standardId ?? ''] = {
id: object.id,
fields: object.fields.reduce((acc, field) => {
// @ts-expect-error legacy noImplicitAny
acc[field.standardId ?? ''] = field.id;
return acc;

View File

@ -18,6 +18,7 @@ export const standardObjectsPrefillData = async (
throw new Error('Standard Id is not set for object: ${object.name}');
}
// @ts-expect-error legacy noImplicitAny
acc[object.standardId] = {
id: object.id,
fields: object.fields.reduce((acc, field) => {
@ -25,6 +26,7 @@ export const standardObjectsPrefillData = async (
throw new Error('Standard Id is not set for field: ${field.name}');
}
// @ts-expect-error legacy noImplicitAny
acc[field.standardId] = field.id;
return acc;

View File

@ -134,6 +134,7 @@ export class WorkspaceDefaultValueFixer extends AbstractWorkspaceFixer<Workspace
continue;
}
// @ts-expect-error legacy noImplicitAny
const value = currentDefaultValue[key];
const newValue =

View File

@ -303,7 +303,8 @@ export class DatabaseStructureService {
normalizer(
compositeProperty.type,
typeof initialDefaultValue === 'object'
? initialDefaultValue?.[compositeProperty.name]
? // @ts-expect-error legacy noImplicitAny
initialDefaultValue?.[compositeProperty.name]
: null,
),
);

View File

@ -18,9 +18,11 @@ describe('WorkspaceRelationComparator', () => {
}
it('should generate CREATE action for new relations', () => {
// @ts-expect-error legacy noImplicitAny
const original = [];
const standard = [createMockRelationMetadata({})];
// @ts-expect-error legacy noImplicitAny
const result = comparator.compare(original, standard);
expect(result).toEqual([
@ -36,8 +38,10 @@ describe('WorkspaceRelationComparator', () => {
it('should generate DELETE action for removed relations', () => {
const original = [createMockRelationMetadata({ id: '1' })];
// @ts-expect-error legacy noImplicitAny
const standard = [];
// @ts-expect-error legacy noImplicitAny
const result = comparator.compare(original, standard);
expect(result).toEqual([

View File

@ -51,10 +51,12 @@ export function transformMetadataForComparison<T, Keys extends keyof T>(
) {
const orderedValue = orderObjectProperties(datum[property] as object);
// @ts-expect-error legacy noImplicitAny
transformedField[property as string] = JSON.stringify(
orderedValue,
) as T[Keys];
} else {
// @ts-expect-error legacy noImplicitAny
transformedField[property as string] = datum[property];
}
}

View File

@ -183,8 +183,10 @@ export class WorkspaceFieldRelationComparator {
}
}
// @ts-expect-error legacy noImplicitAny
propertiesMap[fieldId][property] = newValue;
} else {
// @ts-expect-error legacy noImplicitAny
propertiesMap[fieldId][property] = difference.value;
}
}

View File

@ -191,10 +191,12 @@ export class WorkspaceFieldComparator {
if (
(fieldPropertiesToStringify as readonly string[]).includes(property)
) {
// @ts-expect-error legacy noImplicitAny
fieldPropertiesToUpdateMap[id][property] = this.parseJSONOrString(
difference.value,
);
} else {
// @ts-expect-error legacy noImplicitAny
fieldPropertiesToUpdateMap[id][property] = difference.value;
}
break;

View File

@ -74,6 +74,7 @@ export class WorkspaceObjectComparator {
const property = difference.path[0];
// @ts-expect-error legacy noImplicitAny
objectPropertiesToUpdate[property] = standardObjectMetadata[property];
}
}