Live data from Hacker News

TypeScripting the technical interview

richard-towers.com

41–50 of 180 posts

Re: TypeScripting the technical interview

#44
post #16

TypeScript has the most complicated type system ever. Don't know why Anders&Co needed to go that far.

As much as people complain about the TS type system’s complexity, it is just modeling real world JS. The vast majority of its complexity is hardly used in TS that doesn’t interop with existing JS, because you generally won’t write such highly dynamic code when you have to define its types. But it does allow for safer interop. Even so, JS itself being so dynamic, TS still can’t claim full type safety. And as much as p…

> TS that doesn’t interop with existing JS

which tends to happen at the edge of the application where it interacts with the outside world and all the interesting things happen.

Re: TypeScripting the technical interview

#45

In case folks miss the link at the top of the article, this is translated from an old 2017 post by Aphyr. That post was in Haskell, where it's not too surprising that you can do serious computation inside the type system. This new post translates the ideas to TypeScript, which is more widely known, and which I once heard described as having "accidentally Turing-complete" types: https://github.com/microsoft/TypeScript…

Aphyr has a series of posts in this style, all of which are excellent.

I love this series. It also reminds me a bit of https://unsongbook.com -- another beautiful work of creative writing combining technology and magic.

Re: TypeScripting the technical interview

#46
If you want to see some more legs on TypeScript type-level logic, check out this SQL database as Typescript types: https://github.com/codemix/ts-sql:

    import { Query } from "@codemix/ts-sql";
    
    const db = {
      things: [
        { id: 1, name: "a", active: true },
        { id: 2, name: "b", active: false },
        { id: 3, name: "c", active: true },
      ],
    } as const;
    
    type ActiveThings = Query;
    
    // ActiveThings is now equal to the following type:
    type Expected = [{ id: 1; nom: "a" }, { id: 3; nom: "c" }];

Re: TypeScripting the technical interview

#47

So he wrote all that for the typescript lsp to respond with the answer, but when it compiles down it's nothing? And we're using runes as variables just because? That is pretty neat, and silly. I also think it highlights my natural aversion to static type checking in dynamic languages. I know that I could get sucked into writing a bunch of code for the checker, instead of using my energy for making the application wor…

this is why i love ts when not working for a megacorp. when the ts gets too cray i just nope out. throw an any or as in there and get on with my day. wouldn't pass a code review but i don't care

Re: TypeScripting the technical interview

#48

So he wrote all that for the typescript lsp to respond with the answer, but when it compiles down it's nothing? And we're using runes as variables just because? That is pretty neat, and silly. I also think it highlights my natural aversion to static type checking in dynamic languages. I know that I could get sucked into writing a bunch of code for the checker, instead of using my energy for making the application wor…

this is why i love ts when not working for a megacorp. when the ts gets too cray i just nope out. throw an any or as in there and get on with my day. wouldn't pass a code review but i don't care

[flagged]

Re: TypeScripting the technical interview

#49

Is this really what technical interviews are like in Silicon Valley? I’ve never seen anything like it in the “real” world.

more or less. i wasn't asked n queens specifically, but i was asked to move a knight from one square to another. but no, you're not supposed to solve it using the type system itself

Re: TypeScripting the technical interview

#50
Why did they only solve for 7 Queens and not 8 Queens?

I'm reminded of https://github.com/type-challenges/type-challenges -- I've only looked at some of the more challenging problems, but one involves writing a JSON parser in the type system. The easy problems look reasonably useful to solve.

Post reply on HN