Hacker News new | past | comments | ask | show | jobs | submit login
A text adventure game on TypeScript's type system (github.com/cassiozen)
293 points by cacozen on Sept 21, 2022 | hide | past | favorite | 31 comments



I never get tired of seeing fun little things like this. Is there a way to make VSCode not truncate the type info?


`noErrorTruncation: true` in a tsconfig.[1] It also affects hover and quickinfo truncation. Technically it will still truncate, just at a way higher limit, like a million characters.

[1]https://www.typescriptlang.org/tsconfig#noErrorTruncation


> Setting "noErrorTruncation": true, as proposed in the previous answer, does not work for this question as asked.

https://stackoverflow.com/questions/62508909/vs-code-how-to-...



For those wanting a TS Playground link: https://tinyurl.com/mw6pbpht


If you have been wondering how much data a uri hash can store. Firefox can handle up to 1M characters, Chromium much more. I did not test Safari and mobile browsers though. This game is at 12k encoded and is far from hitting the limit. https://stackoverflow.com/questions/16247162/max-size-of-loc...


I made a PR to add this link to the readme.


What the fuck


The type system is Turing-complete, after all…

https://github.com/Microsoft/TypeScript/issues/14833


I'm sorry which "What the fuck" are you referring to?


indeed


Related, discussed previously, Type-Level TypeScript: https://news.ycombinator.com/item?id=32913125


So which one should now one study - TypeScript type system, RxJS operators, or the next generation of vomit produced by the Angular team? Together they compose extremely unfunny clusterfuck. For now my CVs all fall into a black hole, you better not fall off the employment train.


An interesting tidbit that I found in the source code is that it only accepts integers from 1 to 20. Perfectly sufficient for its use case, although not quite extendable as I would hope


This is neat. Can someone explain why the generic types extending string need to default to any in all these cases, like: `TDescription extends string = any` ?


It’s just so I can later reuse that type without having to pass in the generic. Like I do on lines 41 and 42


What a beautiful little treat. For everyone curious, it took me less than ten minutes to play through. Well done!


This is really neat, thanks!


How do you play the game?


git clone, make sure TypeScript is installed, and open src/index.ts

Would be nice if this was exported to some TypeScript playground environment.


Easiest is to just press `.` on the GitHub repo to open the GH dev environment


wait... WHAT!? how is such an amazing feature hidden behind some incredibly obscure keyboard shortcut? this completely changes how I'll explore Github.


what am I doing wrong. 'press . on the Github repo' ?


Just open the repository and type a dot on your keyboard. You don't need to select anything.


With the page open in your browser, press the "." key on your keyboard.


I'm really surprised I've never even discovered that accidentally. If nothing else, this is a vastly superior way to search a repository.


It was added about a year ago so it's fairly recent. Before this another group had made this same thing on a different website (turns out a big advantage of Electron apps is they can be converted to web apps without TOO much difficulty). With that one you'd just replace the domain of the URL with whatever that website was


Too bad there is no such thing as HN comment of the week, this would be it.


wtf! I had no idea this existed!


Weirdly, a spider killing me isn't the worst thing I've seen written in Typescript.


Lol




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: