From 7a9c051e55c3256160d1ee461bc13a519e8f843b Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Tue, 19 Aug 2025 12:30:41 +0200 Subject: [PATCH 1/6] Add unit test to make sure issue 1297 will not be introduced again in the future --- package-lock.json | 1 + package.json | 1 - test/unit/cruds/change-cell-content.spec.ts | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index ccc091b3ec..3715a7301f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15563,6 +15563,7 @@ "resolved": "https://registry.npmjs.org/karma-firefox-launcher/-/karma-firefox-launcher-2.1.3.tgz", "integrity": "sha512-LMM2bseebLbYjODBOVt7TCPP9OI2vZIXCavIXhkO9m+10Uj5l7u/SKoeRmYx8FYHTVGZSpk6peX+3BMHC1WwNw==", "dev": true, + "license": "MIT", "dependencies": { "is-wsl": "^2.2.0", "which": "^3.0.0" diff --git a/package.json b/package.json index bf22060624..c6c242b53e 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,6 @@ "test": "npm-run-all lint test:unit test:browser test:compatibility", "test:unit": "cross-env NODE_ICU_DATA=node_modules/full-icu jest", "test:watch": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch", - "test:watch-tdd": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch xlookup", "test:coverage": "npm run test:unit -- --coverage", "test:logMemory": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --runInBand --logHeapUsage", "test:unit.ci": "cross-env NODE_ICU_DATA=node_modules/full-icu node --expose-gc ./node_modules/jest/bin/jest --forceExit", diff --git a/test/unit/cruds/change-cell-content.spec.ts b/test/unit/cruds/change-cell-content.spec.ts index c8c5a9b7c3..d34f09f32a 100644 --- a/test/unit/cruds/change-cell-content.spec.ts +++ b/test/unit/cruds/change-cell-content.spec.ts @@ -582,6 +582,20 @@ describe('changing cell content', () => { expect(engine.getCellValueDetailedType({ sheet: 0, col: 0, row: 1 })).toEqual(CellValueDetailedType.NUMBER_CURRENCY) expect(engine.getCellValueDetailedType({ sheet: 0, col: 0, row: 2 })).toEqual(CellValueDetailedType.NUMBER_PERCENT) }) + + it('should work in scenario from issue https://github.com/handsontable/hyperformula/issues/1297', () => { + const engine = HyperFormula.buildFromArray([ + [1, 2, '=SUM(A1:B1)'], + ['=SUM(1:1)', 0, 0], + ['=SUM(1:2)', 0, 0], + ]) + + engine.setCellContents(adr('C1'), [['=SUM(A1:B1)']]) + engine.setCellContents(adr('A3'), [['=SUM(A1:C2)']]) + engine.setCellContents(adr('B1'), [[null]]) + + expect(engine.getCellValue(adr('A3'))).toEqual(4) + }) }) describe('change multiple cells contents', () => { From 0456deff952d5cb6219bd9401e56267d29da6e11 Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Mon, 1 Sep 2025 16:44:33 +0200 Subject: [PATCH 2/6] Disable 'Unchanged files with check annotations' section in PR --- .github/workflows/lint.yml | 6 ++++++ test/unit/cruds/change-cell-content.spec.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 792b2f30dd..564207252f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,6 +30,12 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Disable 'Unchanged files with check annotations' section # https://github.com/orgs/community/discussions/8379 + run: | + echo "::remove-matcher owner=eslint-compact::" + echo "::remove-matcher owner=eslint-stylish::" + echo "::remove-matcher owner=tsc::" + - name: Install dependencies run: | npm ci diff --git a/test/unit/cruds/change-cell-content.spec.ts b/test/unit/cruds/change-cell-content.spec.ts index d34f09f32a..bc84c65c54 100644 --- a/test/unit/cruds/change-cell-content.spec.ts +++ b/test/unit/cruds/change-cell-content.spec.ts @@ -583,7 +583,7 @@ describe('changing cell content', () => { expect(engine.getCellValueDetailedType({ sheet: 0, col: 0, row: 2 })).toEqual(CellValueDetailedType.NUMBER_PERCENT) }) - it('should work in scenario from issue https://github.com/handsontable/hyperformula/issues/1297', () => { + it("should work in scenario from issue https://github.com/handsontable/hyperformula/issues/1297", () => { const engine = HyperFormula.buildFromArray([ [1, 2, '=SUM(A1:B1)'], ['=SUM(1:1)', 0, 0], From ac776140d00ddca0072964796fe512a215082f1a Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Mon, 1 Sep 2025 16:59:48 +0200 Subject: [PATCH 3/6] Revert last commit --- .github/workflows/lint.yml | 6 ------ test/unit/cruds/change-cell-content.spec.ts | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 564207252f..792b2f30dd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,12 +30,6 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Disable 'Unchanged files with check annotations' section # https://github.com/orgs/community/discussions/8379 - run: | - echo "::remove-matcher owner=eslint-compact::" - echo "::remove-matcher owner=eslint-stylish::" - echo "::remove-matcher owner=tsc::" - - name: Install dependencies run: | npm ci diff --git a/test/unit/cruds/change-cell-content.spec.ts b/test/unit/cruds/change-cell-content.spec.ts index bc84c65c54..d34f09f32a 100644 --- a/test/unit/cruds/change-cell-content.spec.ts +++ b/test/unit/cruds/change-cell-content.spec.ts @@ -583,7 +583,7 @@ describe('changing cell content', () => { expect(engine.getCellValueDetailedType({ sheet: 0, col: 0, row: 2 })).toEqual(CellValueDetailedType.NUMBER_PERCENT) }) - it("should work in scenario from issue https://github.com/handsontable/hyperformula/issues/1297", () => { + it('should work in scenario from issue https://github.com/handsontable/hyperformula/issues/1297', () => { const engine = HyperFormula.buildFromArray([ [1, 2, '=SUM(A1:B1)'], ['=SUM(1:1)', 0, 0], From 754ce2e7576ffbd8e8846e724a01860c974de8cf Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Mon, 6 Oct 2025 11:05:39 +0200 Subject: [PATCH 4/6] Revert change made by mistake --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c6c242b53e..bf22060624 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,7 @@ "test": "npm-run-all lint test:unit test:browser test:compatibility", "test:unit": "cross-env NODE_ICU_DATA=node_modules/full-icu jest", "test:watch": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch", + "test:watch-tdd": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --watch xlookup", "test:coverage": "npm run test:unit -- --coverage", "test:logMemory": "cross-env NODE_ICU_DATA=node_modules/full-icu jest --runInBand --logHeapUsage", "test:unit.ci": "cross-env NODE_ICU_DATA=node_modules/full-icu node --expose-gc ./node_modules/jest/bin/jest --forceExit", From d16f1c4d3d87efd205f260e333e3077587da3ee9 Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Mon, 6 Oct 2025 11:36:26 +0200 Subject: [PATCH 5/6] Add jsdoc comment --- src/AbsoluteCellRange.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AbsoluteCellRange.ts b/src/AbsoluteCellRange.ts index 0b9585fb6d..47adbe7ed7 100644 --- a/src/AbsoluteCellRange.ts +++ b/src/AbsoluteCellRange.ts @@ -26,7 +26,12 @@ export interface SimpleCellRange { end: SimpleCellAddress, } -export function isSimpleCellRange(obj: any): obj is SimpleCellRange { +/** + * Type guard that checks if an object is a valid SimpleCellRange. + * @param {unknown} obj - The object to check + * @returns {boolean} True if and only if the object is a valid SimpleCellRange + */ +export function isSimpleCellRange(obj: unknown): obj is SimpleCellRange { if (obj && (typeof obj === 'object' || typeof obj === 'function')) { return 'start' in obj && isSimpleCellAddress(obj.start) && 'end' in obj && isSimpleCellAddress(obj.end) } else { From b4c7df6331ef0d8ce9a7c2c72b24545ca8083775 Mon Sep 17 00:00:00 2001 From: Kuba Sekowski Date: Mon, 6 Oct 2025 11:45:44 +0200 Subject: [PATCH 6/6] Fix type error --- src/AbsoluteCellRange.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/AbsoluteCellRange.ts b/src/AbsoluteCellRange.ts index 47adbe7ed7..6cba3c563f 100644 --- a/src/AbsoluteCellRange.ts +++ b/src/AbsoluteCellRange.ts @@ -28,11 +28,12 @@ export interface SimpleCellRange { /** * Type guard that checks if an object is a valid SimpleCellRange. - * @param {unknown} obj - The object to check + * @param {unknown} val - Value to check * @returns {boolean} True if and only if the object is a valid SimpleCellRange */ -export function isSimpleCellRange(obj: unknown): obj is SimpleCellRange { - if (obj && (typeof obj === 'object' || typeof obj === 'function')) { +export function isSimpleCellRange(val: unknown): val is SimpleCellRange { + if (val && (typeof val === 'object' || typeof val === 'function')) { + const obj = val as Record return 'start' in obj && isSimpleCellAddress(obj.start) && 'end' in obj && isSimpleCellAddress(obj.end) } else { return false