Skip to content

Harden unchecked indexed access#2297

Open
ace2016 wants to merge 3 commits into
mito-ds:devfrom
ace2016:fix/issue-179-undefined-type-safety
Open

Harden unchecked indexed access#2297
ace2016 wants to merge 3 commits into
mito-ds:devfrom
ace2016:fix/issue-179-undefined-type-safety

Conversation

@ace2016

@ace2016 ace2016 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

Enable noUncheckedIndexedAccess for the frontend TypeScript project and fix the resulting undefined-indexed-access errors across the codebase.

This fixes issue #179.

Motivation:
the issue called out a recurring class of sheet crashes caused by indexing into arrays and records, then immediately treating the result as definitely defined. This change strengthens the type system so those lookups are typed as possibly undefined, then updates call sites to handle that explicitly.

Scope:

  • enabled noUncheckedIndexedAccess in mitosheet/tsconfig.json
  • fixed frontend TypeScript errors introduced by the flag across grid, taskpane, graph, import, viewer, wrapper, and utility modules
  • used explicit guards, optional chaining, and nullish coalescing instead of non-null assertions
  • added a small number of console.warn(...) / early returns where missing values would indicate an unexpected state

This is intended as a type-safety improvement only. Normal UI behavior should remain the same, while invalid edge cases should fail more safely instead of crashing.

Testing

Ways to access or use the affected functionality that were covered by the type-safety pass:

  • opening the main sheet/grid UI
  • editing cells and using the cell editor
  • selecting rows, columns, and cells
  • using toolbar and keyboard-driven actions
  • opening control panel taskpanes
  • using graph setup and graph sidebar flows
  • using pivot table setup flows
  • using merge flows
  • using import/update import flows
  • using conditional formatting flows
  • using viewer rendering and column resize behavior
  • using Jupyter / Dash / Streamlit wrapper paths that read backend responses

Validation performed:

  • ran npx tsc --noEmit in mitosheet with noUncheckedIndexedAccess: true
  • confirmed the compiler passes cleanly after the fixes

Manual/runtime testing:

  • I have tested this on real data that is reasonable and large
  • If I changed the interaction with JupyterLab, I tested that it does not break other programs (like VS Code), and tested that it works "multiple times" in the same notebook.

Documentation

No documentation changes required.

@vercel

vercel Bot commented May 4, 2026

Copy link
Copy Markdown

@ace2016 is attempting to deploy a commit to the trymito Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant