O'Reilly logo

TypeScript Blueprints by Ivo Gabe de Wolff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining the sheet

A spreadsheet will be a grid of fields. Every field can contain a string or an expression, as demonstrated in the following screenshot:

Defining the sheet

In lib/model/sheet.ts, we will define the sheet and create functions to parse, show and calculate all expressions in the field.

First, we will import types and functions that we will use in this file.

import { Expression, Variable, calculateExpression, Constant, Failure, FailureKind, validate, expressionToString } from "./expression"; 
import { parse, parseConstant, parseExpression} from "./parser"; 

We can define a field as an expression or a string, and a sheet as a grid of fields:

export type Field ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required