All JavaScript and TypeScript features of the last 3 years explained

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • dedent

    ⬅️ ES6 string tag that strips indentation from multi-line strings.

    and so `dedent` would not strip any indentation. That is, `dedent` is meant to identify the maximal common leading indentation in the template as written by the developer, which should not depend on the values of the interpolands.

    A stale GitHub issue on the dmnd/dedent repo has a real-world example where this matters and led to a subtle bug: https://github.com/dmnd/dedent/issues/22

  • proposal-class-fields

    Discontinued Orthogonally-informed combination of public and private fields proposals

    The # sigil has always bummed me out too.

    Supposedly it's because of this:

    > Why isn't access this.x?

    > Having a private field named x must not prevent there from being a public field named x, so accessing a private field can't just be a normal lookup.

    https://github.com/tc39/proposal-class-fields/blob/main/PRIV...

    Combined with this:

    > Why aren't declarations private x?

    > This sort of declaration is what other languages use (notably Java), and implies that access would be done with this.x. Assuming that isn't the case (see above), in JavaScript this would silently create or access a public field, rather than throwing an error. This is a major potential source of bugs or invisibly making public fields which were intended to be private.

    https://github.com/tc39/proposal-class-fields/blob/main/PRIV...

    But I still think it's weird.

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • proposal-iterator-helpers

    Methods for working with iterators in ECMAScript

    > focus more on improving the terrible JS web API

    That's W3C’s job, not ECMA’s.

    > Where are all the containers?

    ?

    > Sorted sets/maps?

    Sets and Maps are sorted (by insertion order)

    > Why can't I even map an iterator?

    It's coming, but someone will likely be exhausted by that addition. https://github.com/tc39/proposal-iterator-helpers

  • proposal-private-fields

    Discontinued A Private Fields Proposal for ECMAScript

    > - # private... not sure why they didn't just use the "private" keyword, but I don't care. I almost always use TypeScript anyways

    One of the reasons was to allow private and public fields of the same name, so that subclasses are free to add own public fields without accidentally discovering private fields. There were many more considerations that went into the design: https://github.com/tc39/proposal-class-fields/blob/main/PRIV....

    There was a heated debate about this and the choice of the # sigil back in 2015 at the time private fields were being designed: https://github.com/tc39/proposal-private-fields/issues/14.

  • slonik

    A Node.js PostgreSQL client with runtime and build time type safety, and composable SQL.

    Definitely a lot of misconceptions around how this would work. Just check out something like slonik, https://github.com/gajus/slonik, which is an excellent implementation.

    The example you gave actually isn't valid, because what you're doing is generating SQL dynamically, and that doesn't work the way prepared statements work. That is, you can't have a prepared statement like "select foo from bar where zed = ? order by ? asc", because with prepared statements the question marks can only substitute for VALUES, not schema names. So if you wanted to do something like that it slonik, it would fail. With slonik you CAN do dynamic SQL, that is guaranteed to be safe and checked at compile time with TypeScript, because you can nest SQL tagged template. That is you can do this:

        const colToSortBy = useFoo ? sql`foo` : sql`bar`;

  • TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    Some folks have built whole SQL databases and DSL compilers in the TS type system. These tend to be toy projects with disclaimers not to use them. But the type system being Turing complete[0] (for better or worse), pretty much whatever you can imagine. This project[1] is one I actually return to frequently for practical ideas.

    0: https://github.com/microsoft/TypeScript/issues/14833

    1: https://github.com/sindresorhus/type-fest

  • type-fest

    A collection of essential TypeScript types

    Some folks have built whole SQL databases and DSL compilers in the TS type system. These tend to be toy projects with disclaimers not to use them. But the type system being Turing complete[0] (for better or worse), pretty much whatever you can imagine. This project[1] is one I actually return to frequently for practical ideas.

    0: https://github.com/microsoft/TypeScript/issues/14833

    1: https://github.com/sindresorhus/type-fest

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

  • zod

    TypeScript-first schema validation with static type inference

    You can use discriminated unions with TS (https://antman-does-software.com/typescripts-discriminated-u...), and you can even parse them from unknown data using tools like zod (https://zod.dev/?id=discriminated-unions), io-ts, or the likes.

    I can't think of anything I can do in .NET (which has runtime types) that I can't do in TS with the help of a library or two.

  • arangojs

    The official ArangoDB JavaScript driver.

    We actually did the same for ArangoDB (I think we first did this in 2015, I remember being surprised nobody had done something similar for SQL at the time). Here's the JS driver's current implementation of it:

    https://github.com/arangodb/arangojs/blob/main/src/aql.ts#L1...

    Basically the `aql` template tag returns an object that can also be fed back into it and we also deduplicate arguments to avoid sending redundant data over the wire. There's also an escape hatch via a helper function (`aql.literal`) in cases where you need to insert literals that aren't known at compile time (e.g. you load query filters from a configuration file).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts