@@ -14,6 +14,12 @@ import {
1414 TextRun ,
1515} from 'omniscript-parser' ;
1616
17+ // Type definitions for formula handling
18+ interface FormulaDefinition {
19+ cell : [ number , number ] ;
20+ expr : string ;
21+ }
22+
1723// Type for spreadsheet cell values (compatible with OSFValue)
1824type CellValue = string | number | boolean ;
1925
@@ -116,7 +122,7 @@ class FormulaEvaluator {
116122 private computed : Map < string , CellValue > ;
117123 private evaluating : Set < string > ; // For circular reference detection
118124
119- constructor ( data : SpreadsheetData , formulas : { cell : [ number , number ] ; expr : string } [ ] ) {
125+ constructor ( data : SpreadsheetData , formulas : FormulaDefinition [ ] ) {
120126 this . data = { ...data } ;
121127 this . formulas = new Map ( ) ;
122128 this . computed = new Map ( ) ;
@@ -493,7 +499,7 @@ function renderHtml(doc: OSFDocument): string {
493499
494500 // Calculate dimensions including formula cells
495501 const dataCoords = Object . keys ( sheet . data ) . map ( k => k . split ( ',' ) . map ( Number ) ) ;
496- const formulaCoords = ( sheet . formulas || [ ] ) . map ( f => f . cell ) ;
502+ const formulaCoords = ( sheet . formulas || [ ] ) . map ( ( f : FormulaDefinition ) => f . cell ) ;
497503 const allCoords = [ ...dataCoords , ...formulaCoords ] ;
498504
499505 const maxRow = Math . max ( ...allCoords . map ( c => c [ 0 ] || 0 ) ) ;
@@ -508,7 +514,9 @@ function renderHtml(doc: OSFDocument): string {
508514 for ( let c = 1 ; c <= maxCol ; c ++ ) {
509515 const key = `${ r } ,${ c } ` ;
510516 const val = allValues [ key ] ?? '' ;
511- const hasFormula = sheet . formulas ?. some ( f => f . cell [ 0 ] === r && f . cell [ 1 ] === c ) ;
517+ const hasFormula = sheet . formulas ?. some (
518+ ( f : FormulaDefinition ) => f . cell [ 0 ] === r && f . cell [ 1 ] === c
519+ ) ;
512520 const isError = typeof val === 'string' && val . startsWith ( '#ERROR:' ) ;
513521
514522 const cssClass = isError ? 'error' : hasFormula ? 'computed' : '' ;
@@ -630,7 +638,7 @@ function exportMarkdown(doc: OSFDocument): string {
630638
631639 // Calculate dimensions including formula cells
632640 const dataCoords = Object . keys ( sheet . data ) . map ( k => k . split ( ',' ) . map ( Number ) ) ;
633- const formulaCoords = ( sheet . formulas || [ ] ) . map ( f => f . cell ) ;
641+ const formulaCoords = ( sheet . formulas || [ ] ) . map ( ( f : FormulaDefinition ) => f . cell ) ;
634642 const allCoords = [ ...dataCoords , ...formulaCoords ] ;
635643
636644 const maxRow = Math . max ( ...allCoords . map ( c => c [ 0 ] || 0 ) ) ;
@@ -644,7 +652,9 @@ function exportMarkdown(doc: OSFDocument): string {
644652 for ( let c = 1 ; c <= maxCol ; c ++ ) {
645653 const key = `${ r } ,${ c } ` ;
646654 const val = allValues [ key ] ?? '' ;
647- const hasFormula = sheet . formulas ?. some ( f => f . cell [ 0 ] === r && f . cell [ 1 ] === c ) ;
655+ const hasFormula = sheet . formulas ?. some (
656+ ( f : FormulaDefinition ) => f . cell [ 0 ] === r && f . cell [ 1 ] === c
657+ ) ;
648658
649659 if ( hasFormula && typeof val === 'number' ) {
650660 // Show computed value with indication it's calculated
@@ -706,7 +716,7 @@ function exportJson(doc: OSFDocument): string {
706716
707717 // Calculate dimensions including formula cells
708718 const dataCoords = Object . keys ( sheet . data ) . map ( ( k : string ) => k . split ( ',' ) . map ( Number ) ) ;
709- const formulaCoords = ( sheet . formulas || [ ] ) . map ( f => f . cell ) ;
719+ const formulaCoords = ( sheet . formulas || [ ] ) . map ( ( f : FormulaDefinition ) => f . cell ) ;
710720 const allCoords = [ ...dataCoords , ...formulaCoords ] ;
711721
712722 const maxRow = Math . max ( ...allCoords . map ( c => c [ 0 ] || 0 ) ) ;
@@ -718,7 +728,9 @@ function exportJson(doc: OSFDocument): string {
718728 // Convert to array format with computed values
719729 const computedData = Object . entries ( allValues ) . map ( ( [ cell , value ] ) => {
720730 const [ r , c ] = cell . split ( ',' ) . map ( Number ) ;
721- const hasFormula = sheet . formulas ?. some ( f => f . cell [ 0 ] === r && f . cell [ 1 ] === c ) ;
731+ const hasFormula = sheet . formulas ?. some (
732+ ( f : FormulaDefinition ) => f . cell [ 0 ] === r && f . cell [ 1 ] === c
733+ ) ;
722734 return {
723735 row : r ,
724736 col : c ,
0 commit comments