From 6c610a31819e26d7aba19e633a5d545dd898e259 Mon Sep 17 00:00:00 2001 From: adrinr Date: Thu, 30 Mar 2023 10:21:50 +0100 Subject: [PATCH] Types (with forced checks!) --- packages/server/src/api/controllers/table/utils.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index 3de4f856f6..7052b8e107 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -111,21 +111,19 @@ export function importToRows(data: any, table: Table, user: any = {}) { row = processed.row table = processed.table - let fieldName: any - let schema: any - for ([fieldName, schema] of Object.entries(table.schema)) { + for (const [fieldName, schema] of Object.entries(table.schema)) { // check whether the options need to be updated for inclusion as part of the data import if ( schema.type === FieldTypes.OPTIONS && row[fieldName] && - (!schema.constraints.inclusion || - schema.constraints.inclusion.indexOf(row[fieldName]) === -1) + (!schema.constraints!.inclusion || + schema.constraints!.inclusion.indexOf(row[fieldName]) === -1) ) { - schema.constraints.inclusion = [ - ...schema.constraints.inclusion, + schema.constraints!.inclusion = [ + ...schema.constraints!.inclusion!, row[fieldName], ] - schema.constraints.inclusion.sort() + schema.constraints!.inclusion.sort() } }