Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): fix some TypeScript 5.x related errors #886

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/common/src/editorValidators/floatValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ export function floatValidator(inputValue: any, options: FloatValidatorOptions):
// when decimal value is 0 (which is the default), we accept 0 or more decimal values
isValid = false;
outputMsg = errorMsg || Constants.VALIDATION_EDITOR_VALID_NUMBER;
} else if (minValue !== undefined && maxValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && (floatNumber <= minValue || floatNumber >= maxValue)) || (operatorConditionalType === 'inclusive' && (floatNumber < minValue || floatNumber > maxValue)))) {
} else if (minValue !== undefined && maxValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && (floatNumber <= +minValue || floatNumber >= +maxValue)) || (operatorConditionalType === 'inclusive' && (floatNumber < +minValue || floatNumber > +maxValue)))) {
// MIN & MAX Values provided
// when decimal value is bigger than 0, we only accept the decimal values as that value set
// for example if we set decimalPlaces to 2, we will only accept numbers between 0 and 2 decimals
isValid = false;
outputMsg = errorMsg || Constants.VALIDATION_EDITOR_NUMBER_BETWEEN.replace(/{{minValue}}|{{maxValue}}/gi, (matched) => (mapValidation as any)[matched]);
} else if (minValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && floatNumber <= minValue) || (operatorConditionalType === 'inclusive' && floatNumber < minValue))) {
} else if (minValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && floatNumber <= +minValue) || (operatorConditionalType === 'inclusive' && floatNumber < +minValue))) {
// MIN VALUE ONLY
// when decimal value is bigger than 0, we only accept the decimal values as that value set
// for example if we set decimalPlaces to 2, we will only accept numbers between 0 and 2 decimals
isValid = false;
const defaultErrorMsg = operatorConditionalType === 'inclusive' ? Constants.VALIDATION_EDITOR_NUMBER_MIN_INCLUSIVE : Constants.VALIDATION_EDITOR_NUMBER_MIN;
outputMsg = errorMsg || defaultErrorMsg.replace(/{{minValue}}/gi, (matched) => (mapValidation as any)[matched]);
} else if (maxValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && floatNumber >= maxValue) || (operatorConditionalType === 'inclusive' && floatNumber > maxValue))) {
} else if (maxValue !== undefined && floatNumber !== null && ((operatorConditionalType === 'exclusive' && floatNumber >= +maxValue) || (operatorConditionalType === 'inclusive' && floatNumber > +maxValue))) {
// MAX VALUE ONLY
// when decimal value is bigger than 0, we only accept the decimal values as that value set
// for example if we set decimalPlaces to 2, we will only accept numbers between 0 and 2 decimals
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/editorValidators/integerValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ export function integerValidator(inputValue: any, options: IntegerValidatorOptio
} else if (inputValue !== '' && ((isNaN(inputValue as number) || !/^[+-]?\d+$/.test(inputValue)))) {
isValid = false;
outputMsg = errorMsg || Constants.VALIDATION_EDITOR_VALID_INTEGER;
} else if (minValue !== undefined && maxValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && (intNumber <= minValue || intNumber >= maxValue)) || (operatorConditionalType === 'inclusive' && (intNumber < minValue || intNumber > maxValue)))) {
} else if (minValue !== undefined && maxValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && (intNumber <= +minValue || intNumber >= +maxValue)) || (operatorConditionalType === 'inclusive' && (intNumber < +minValue || intNumber > +maxValue)))) {
// MIN & MAX Values provided (between)
// when decimal value is bigger than 0, we only accept the decimal values as that value set
// for example if we set decimalPlaces to 2, we will only accept numbers between 0 and 2 decimals
isValid = false;
outputMsg = errorMsg || Constants.VALIDATION_EDITOR_INTEGER_BETWEEN.replace(/{{minValue}}|{{maxValue}}/gi, (matched) => (mapValidation as any)[matched]);
} else if (minValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && intNumber <= minValue) || (operatorConditionalType === 'inclusive' && intNumber !== null && intNumber < minValue))) {
} else if (minValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && intNumber <= +minValue) || (operatorConditionalType === 'inclusive' && intNumber !== null && intNumber < +minValue))) {
// MIN VALUE ONLY
// when decimal value has to be higher then provided minValue
isValid = false;
const defaultErrorMsg = operatorConditionalType === 'inclusive' ? Constants.VALIDATION_EDITOR_INTEGER_MIN_INCLUSIVE : Constants.VALIDATION_EDITOR_INTEGER_MIN;
outputMsg = errorMsg || defaultErrorMsg.replace(/{{minValue}}/gi, (matched) => (mapValidation as any)[matched]);
} else if (maxValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && intNumber >= maxValue) || (operatorConditionalType === 'inclusive' && intNumber !== null && intNumber > maxValue))) {
} else if (maxValue !== undefined && intNumber !== null && ((operatorConditionalType === 'exclusive' && intNumber >= +maxValue) || (operatorConditionalType === 'inclusive' && intNumber !== null && intNumber > +maxValue))) {
// MAX VALUE ONLY
// when decimal value has to be lower then provided maxValue
isValid = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export class SlickCompositeEditorComponent implements ExternalResource {
this._modalElm = createDomElement('div', { className: `slick-editor-modal ${gridUid}` });
const modalContentElm = createDomElement('div', { className: 'slick-editor-modal-content' });

if (viewColumnLayout > 1 || (viewColumnLayout === 'auto' && layoutColCount > 1)) {
if ((!isNaN(viewColumnLayout as number) && +viewColumnLayout > 1) || (viewColumnLayout === 'auto' && layoutColCount > 1)) {
const splitClassName = layoutColCount === 2 ? 'split-view' : 'triple-split-view';
modalContentElm.classList.add(splitClassName);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/excel-export/src/excelExport.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
if (itemMetadata?.columns) {
const metadata = itemMetadata.columns;
const columnData = metadata[columnDef.id] || metadata[col];
if (!(prevColspan > 1 || (prevColspan === '*' && col > 0))) {
if (!((!isNaN(prevColspan as number) && +prevColspan > 1) || (prevColspan === '*' && col > 0))) {
prevColspan = columnData?.colspan ?? 1;
}
if (prevColspan === '*') {
Expand All @@ -533,7 +533,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
}

// when using grid with colspan, we will merge some cells together
if ((prevColspan === '*' && col > 0) || (prevColspan > 1 && columnDef.id !== colspanColumnId)) {
if ((prevColspan === '*' && col > 0) || ((!isNaN(prevColspan as number) && +prevColspan > 1) && columnDef.id !== colspanColumnId)) {
// -- Merge Data
// Excel row starts at 2 or at 3 when dealing with pre-header grouping
const excelRowNumber = row + (this._hasColumnTitlePreHeader ? 3 : 2);
Expand All @@ -553,7 +553,7 @@ export class ExcelExportService implements ExternalResource, BaseExcelExportServ
}

// decrement colspan until we reach colspan of 1 then proceed with cell merge OR full row merge when colspan is (*)
if (typeof prevColspan === 'number' && prevColspan > 1) {
if (typeof prevColspan === 'number' && (!isNaN(prevColspan as number) && +prevColspan > 1)) {
colspan = prevColspan--;
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions packages/text-export/src/textExport.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export class TextExportService implements ExternalResource, BaseTextExportServic
if (itemMetadata?.columns) {
const metadata = itemMetadata?.columns;
const columnData = metadata[columnDef.id] || metadata[col];
if (!(prevColspan > 1 || (prevColspan === '*' && col > 0))) {
if (!((!isNaN(prevColspan as number) && +prevColspan > 1) || (prevColspan === '*' && col > 0))) {
prevColspan = columnData?.colspan ?? 1;
}
if (prevColspan !== '*') {
Expand All @@ -372,9 +372,9 @@ export class TextExportService implements ExternalResource, BaseTextExportServic
}
}

if ((prevColspan === '*' && col > 0) || (prevColspan > 1 && columnDef.id !== colspanColumnId)) {
if ((prevColspan === '*' && col > 0) || ((!isNaN(prevColspan as number) && +prevColspan > 1) && columnDef.id !== colspanColumnId)) {
rowOutputStrings.push('');
if (prevColspan > 1) {
if ((!isNaN(prevColspan as number) && +prevColspan > 1)) {
(prevColspan as number)--;
}
} else {
Expand Down