[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

@ -96,6 +96,7 @@ export class DistantTableService {
await entityManager.query(`DROP SCHEMA "${tmpSchemaName}" CASCADE`);
return createdForeignTableNames.reduce(
// @ts-expect-error legacy noImplicitAny
(acc, { table_name, column_name, data_type, udt_name }) => {
if (!acc[table_name]) {
acc[table_name] = [];

View File

@ -41,11 +41,15 @@ export class ForeignTableService {
await this.workspaceDataSourceService.connectToMainDataSource();
return (
await mainDataSource.query(
`SELECT foreign_table_name, foreign_server_name FROM information_schema.foreign_tables WHERE foreign_server_name = $1`,
[foreignDataWrapperId],
(
await mainDataSource.query(
`SELECT foreign_table_name, foreign_server_name FROM information_schema.foreign_tables WHERE foreign_server_name = $1`,
[foreignDataWrapperId],
)
)
).map((foreignTable) => foreignTable.foreign_table_name);
// @ts-expect-error legacy noImplicitAny
.map((foreignTable) => foreignTable.foreign_table_name)
);
}
public async createForeignTable(

View File

@ -62,6 +62,7 @@ export class RemoteTableSchemaUpdateService {
const tableName = remoteTable.distantTableName;
if (!distantTable) {
// @ts-expect-error legacy noImplicitAny
updates[tableName] = [DistantTableUpdate.TABLE_DELETED];
continue;
}
@ -78,13 +79,17 @@ export class RemoteTableSchemaUpdateService {
);
if (columnsAdded.length > 0) {
// @ts-expect-error legacy noImplicitAny
updates[tableName] = [
// @ts-expect-error legacy noImplicitAny
...(updates[tableName] || []),
DistantTableUpdate.COLUMNS_ADDED,
];
}
if (columnsDeleted.length > 0) {
// @ts-expect-error legacy noImplicitAny
updates[tableName] = [
// @ts-expect-error legacy noImplicitAny
...(updates[tableName] || []),
DistantTableUpdate.COLUMNS_DELETED,
];

View File

@ -16,6 +16,7 @@ export const fetchTableColumns = async (
workspaceId,
);
// @ts-expect-error legacy noImplicitAny
return res.map((column) => ({
columnName: column.column_name,
dataType: column.data_type,

View File

@ -44,10 +44,12 @@ export const buildUpdateRemoteServerRawQuery = (
}
if (remoteServerToUpdate.schema) {
// @ts-expect-error legacy noImplicitAny
options.push(`"schema" = $${parametersPositions['schema']}`);
}
if (remoteServerToUpdate.label) {
// @ts-expect-error legacy noImplicitAny
options.push(`"label" = $${parametersPositions['label']}`);
}
@ -78,6 +80,7 @@ const buildParametersAndPositions = (
Object.entries(remoteServerToUpdate.userMappingOptions).forEach(
([key, value]) => {
parameters.push(value);
// @ts-expect-error legacy noImplicitAny
parametersPositions[key] = parameters.length;
},
);
@ -87,6 +90,7 @@ const buildParametersAndPositions = (
Object.entries(remoteServerToUpdate.foreignDataWrapperOptions).forEach(
([key, value]) => {
parameters.push(value);
// @ts-expect-error legacy noImplicitAny
parametersPositions[key] = parameters.length;
},
);
@ -94,11 +98,13 @@ const buildParametersAndPositions = (
if (remoteServerToUpdate.schema) {
parameters.push(remoteServerToUpdate.schema);
// @ts-expect-error legacy noImplicitAny
parametersPositions['schema'] = parameters.length;
}
if (remoteServerToUpdate.label) {
parameters.push(remoteServerToUpdate.label);
// @ts-expect-error legacy noImplicitAny
parametersPositions['label'] = parameters.length;
}
@ -119,9 +125,11 @@ const buildJsonRawQuery = (
): string => {
const [[firstKey, _], ...followingOptions] = Object.entries(opts);
// @ts-expect-error legacy noImplicitAny
let query = `jsonb_set("${objectName}", '{${firstKey}}', to_jsonb($${parametersPositions[firstKey]}::text))`;
followingOptions.forEach(([key, _]) => {
// @ts-expect-error legacy noImplicitAny
query = `jsonb_set(${query}, '{${key}}', to_jsonb($${parametersPositions[key]}::text))`;
});