DEV Community

Discussion on: How has JavaScript development changed over the last decade?

peerreynders profile image
peerreynders • Edited on

With the proposed types there will be no excuse to use TypeScript in the near future and it will die hopefully

The noise around the Types as Comments proposal seems to confirm that there is a lot of wishful thinking in the industry.

For an example of how the TC39 committee operates look at the ECMAScript Observable proposal from 2015 with the last review in 2017:

"Why does this need to be in the standard library?"

Or in terms of the "Types as Comments" proposal: "How does this need to be part of ECMAScript?".

Clearly it benefits TypeScript but it also delegates the implementation effort to the JavaScript engine teams which cannot derive any benefits as "types are comments".

In conclusion I would be extremely surprised if the "Types as Comments" proposal gets anywhere near Stage 4.

Given the tooling involved from the ECMAScript perspective this is much less invasive:

/*+ (string, string?, string?, string) => string */
function stringsStringStrings(p1, p2, p3, p4 = "test") {
  // TODO
Enter fullscreen mode Exit fullscreen mode

largely inspired by the Hindley–Milner notation used in Haskell - which also happens to cleanly separate TypeScript's type space from ECMAScript's value space.

Basically this approach puts all the effort on the TypeScript team

  • to define a more streamlined version of "types inside comments" as a terser, alternate version to JSDoc (and @type)
  • implement this alongside the existing JSDoc functionality and support it in VS Code
  • go against the historical "types don't belong inside comments" movement
  • convince the existing userbase that interlacing types with names isn't the only way to statically type code.

Simply focusing on promoting @type usage and improving ease of use of all TypeScript features within ECMAScript would be helpful; i.e. streamline today's JSDoc TS features to make TypeScript much more JS friendly.

But even that would be likely ignored by the existing TypeScript userbase because of the familiarity trap even in the face of endorsement by leading personalities.

So it's unlikely that much is going to change in the "typed ECMAScript" landscape (short of V8 just implementing it anyway - but their incentive is pretty low).

jonrandy profile image
Jon Randy

The proposed 'types in comments' stuff belongs in a browser extension for TS developers. It has absolutely no place in the JS engine