From 0779a69cae52ba4ed9e88a626d8beb8507d96f4a Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 14 Nov 2022 11:50:13 +0800 Subject: [PATCH] fix(nc-gui): reduce of empty array with no initial value --- packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts index 01390ecb4e..1e1c50b8de 100644 --- a/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts +++ b/packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts @@ -179,8 +179,10 @@ export default class CSVTemplateAdapter { ) { this.tables[tableIdx].columns[columnIdx].uidt = UITypes.Date // take the date format with the max occurrence - this.tables[tableIdx].columns[columnIdx].meta.date_format = - Object.keys(dateFormat).reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y)) || 'YYYY/MM/DD' + const objKeys = Object.keys(dateFormat) + this.tables[tableIdx].columns[columnIdx].meta.date_format = objKeys.length + ? objKeys.reduce((x, y) => (dateFormat[x] > dateFormat[y] ? x : y)) + : 'YYYY/MM/DD' } else { // Datetime this.tables[tableIdx].columns[columnIdx].uidt = uidt