Skip to content

Comment on Show HN: Conway's Game of Life in TypeScript's type system

Comments

In the typescript playground, the best way to see the output of any evolution number is to have it autocomplete a string literal!

Uncomment one of the PGunXX types that you want to see, then below it type this:

    const boardstr: PGun10 = ``;

Then put the cursor inside the two backticks and press Control+Space for intellisense autocomplete, and press enter on the first entry there. Then intellisense will put the computed board into a string literal, looking like:
    const boardstr: PGun10 = `............................................
    ........................xx..................
    ........................x..x................
    ..........x.x...............x......xx.......
    ........x...x..xxx..........x......xx.......
    .xx.....x...................x...............
    .xx....x....x.......xx..x..x................
    ........x.......x.x..x..xx..................
    ........x...x.....xxx.......................
    ..........x.x...............................
    ............................................`;

You can also use twoslash[1] caret comments in the playground to display type representations inline, even for uninitialized/declared values, so eg something like this should work:

  declare const boardstr: PGun10
  //            ^?
1: https://www.npmjs.com/package/@typescript/twoslash
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.