cubing / cubing.js

🛠 A library for displaying and working with twisty puzzles. Also currently home to the code for Twizzle.
https://js.cubing.net/cubing/
GNU General Public License v3.0
232 stars 42 forks source link

Support `satisfies` #265

Closed lgarron closed 1 year ago

lgarron commented 1 year ago

TypeScript and esbuild support the satisfies operator since a while. This is very handy where you want to make sure to implement a particular API but also expose the way the API is implemented.

A good example is 38eba5d3b13d93568adeb48f3dfac1ed3cebcff6, where I tried to use satisfies to export cube3x3x3, which means that fields like cube3x3x3.stickeringMask are always recognized as present when used in other code.

Unfortunately, npx web-test-runner errors with:

src/cubing/search/inside/solve/puzzles/dynamic/sgs-defs.spec.ts:

 🚧 Browser logs:
      TypeError: Failed to fetch dynamically imported module: http://localhost:8002/src/cubing/search/inside/solve/puzzles/dynamic/sgs-defs.spec.ts?wtr-session-id=vC8D3nECBH1eOEbZndk2C

 ❌ Could not import your test module. Check the browser logs or open the browser in debug mode for more information. 

Error while transforming src/cubing/puzzles/implementations/3x3x3/index.ts: Expected ";" but found "satisfies"
  39 |   stickerings: () => cubeLikeStickeringList("3x3x3"),
  40 |   puzzleSpecificSimplifyOptions: puzzleSpecificSimplifyOptions333,
> 41 | } satisfies PuzzleLoader;
     |  ^
  42 |

Chromium: |██████████████████████████████| 23/23 test files | 138 passed, 0 failed

Error while running tests.

We're using a new enough version of esbuild for these tests, configured here.

I tried updating all the deps to resolve this, but that didn't work. There has to be a solution.