Playing Sudoku in TypeScript while the type checker highlights mistakes

This TypeScript Sudoku experiment aims to define a precise Sudoku type in TypeScript to create a Sudoku game while the type checker detects mistakes. It focuses on complex type definitions rather than implementing a solver. Initially, it defines Sudoku as an array of numbers, ensuring each element is an integer from 1 to 9 and there are exactly 81 elements in a 9×9 grid. The process involves enforcing Sudoku rules like unique rows, columns, and 3×3 squares using Exclude utility type. The article introduces unknown and never types, boolean-like expressions, and cell comparison strategies to ensure Sudoku constraints. However, it acknowledges the complexity and redundancy in the type definitions. The content explores potential approaches and concludes that the experiment is somewhat impractical.

https://github.com/gruhn/typescript-sudoku

To top