Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port to Typescript: first typecheck milestone
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