Skip to content

Commit

Permalink
Port to Typescript: first typecheck milestone
Browse files Browse the repository at this point in the history
The JS types were getting out of hand, with the input graph being
complicated enough as it was, plus the added headaches from component
interfaces and all the internal types in the span splitting algorithms.
The logical solution is to throw strict static types at it, so that's
what I did. Note: still a gaping hole with the `Tk` type of CodeBlock,
which I thought I could get away with keeping abstracted from the
SPANTYs, but unfortunately `candidate` uses it to check if things are
clickable. Will have to move that type up to MainController somehow.

---

Aside: a lot of the pain of manual annotations in this port came from
tuples being inferred as a union list type. There's no nice solution
unfortunately, as for me both `as const` and `tuple()` functions don't
work: the former becuase I then have to put `readonly` everywhere, and
the latter just doesn't convince the typechecker. See
<microsoft/TypeScript#27179> for some
discussion.

The other source of type annotations was the need to label collection
types for some reason, especially in `reduce`, and especially the ad
hoc ones where I really didn't want to write the type of the
accumulator. I think I've been spoiled by Haskell, where I've come to
respect just how predictable and powerful the inference is, and how
fantastic the errors are (mostly thanks to the keyed union types and
non-duck-typing to be fair).
  • Loading branch information
acrylic-origami committed Sep 4, 2020
1 parent cbdc1ef commit a401727
Show file tree
Hide file tree
Showing 18 changed files with 1,720 additions and 819 deletions.
205 changes: 0 additions & 205 deletions web/js-src/CodeBlock.js

This file was deleted.

Loading

0 comments on commit a401727

Please sign in to comment.