Hacker News new | ask | show | jobs
by Tade0 1036 days ago
I started one side project like this recently and it's been great so far.
1 comments

There's a few clunky bits but I hardly ever run into them.

Actually since this conversation is going, here's something I just learned this week that somebody might find helpful. I used to consider enums one of the clunky bits, but I just ran across the `keyof` operator:

    var modeNames = { FOO: 1, BAR: 2 }

    /** @param {keyof modeNames} mode */
    export function doThing(mode) {
        // the jsdoc type above is equivalent to {'FOO'|'BAR'}
    }
Probably old hat to TS people, but since I came at it from the other direction (I'd been using JSDoc for traditional doc-creation reasons before I realized VSCode could use it for linting and type hints) it was news to me.
That is indeed a neat trick!