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...............................
............................................`; declare const boardstr: PGun10
// ^?
1: https://www.npmjs.com/package/@typescript/twoslash[0] https://aphyr.com/posts/342-typing-the-technical-interview
[1] https://www.richard-towers.com/2023/03/11/typescripting-the-...
https://aphyr.com/posts/353-rewriting-the-technical-intervie...
These advanced type systems are essentially a form of pre-compile time scripting to assert certain guarantees about user defined types. It's the same mechanism that makes C++ templates turing complete.
[0] https://www.typescriptlang.org/docs/handbook/2/template-lite...
If feeling adventurous, read e.g. https://lpn.swi-prolog.org/lpnpage.php?pagetype=html&pageid=...
Conditional types are probably rarely used in practial code, but it opens the door for a lot of geekery.
[1] https://www.destroyallsoftware.com/talks/the-birth-and-death...
If anyone else is interested in an internship or full-time position in typescript: https://www.uncountable.com/hiring/hn
Any sufficiently advanced type system is indistinguishable from an interpreter!
type MyType<T> = someFunc(T)
Of course these functions might be typed too…
What I'm saying is that if instead we said that all type annotations must follow existing JS grammar rules, with perhaps a couple of small additions, then we'd be able to support all sorts of complex type annotations in JS directly, using existing syntax. This would mean that TS's grammar would end up changing a bit, but that's a small price to pay for ongoing interoperability.
For example, instead of
type UserProperties = keyof typeof User;
which is tied to TS's arbitrary syntax, and not supported in Flow, use type UserProperties = keyOf(typeOf(User));In college I did it in assembler (a couple hundred bytes of code) on a PDP11/34 and displayed the results on an oscilloscope screen :)