10 votes

A proposal for type syntax in JavaScript

5 comments

  1. Akir
    Link
    I have long wanted optional strict typing in JavaScript. It was basically the only reason why I ever bothered with a build step for JS in the past. Having a completely ignored typing system is a...

    I have long wanted optional strict typing in JavaScript. It was basically the only reason why I ever bothered with a build step for JS in the past.

    Having a completely ignored typing system is a step forward, I guess.

    1 vote
  2. [2]
    Macil
    (edited )
    Link
    The most annoying thing about Typescript is how much configuration it takes to set up in projects, especially when you're using a lot of popular Javascript tools that will each need to be...

    The most annoying thing about Typescript is how much configuration it takes to set up in projects, especially when you're using a lot of popular Javascript tools that will each need to be reconfigured to work with it, and they often each have their own catches to figure out. I find Typescript easily worth going through that for but things can be better.

    I recently picked up Deno for some small projects, which has Typescript support out of the box and an integrated toolset for tests, linting, and formatting, and it's been such a joy. I see this proposal as a way to make this experience more universal through the Javascript software ecosystem.

    1 vote
    1. teaearlgraycold
      Link Parent
      I really want to use deno but I worry it would end up being incompatible with something in the build or production pipeline. Every time you do something non standard in the JS house of cards...

      I really want to use deno but I worry it would end up being incompatible with something in the build or production pipeline. Every time you do something non standard in the JS house of cards you’re risking a ton of effort on making it work.

  3. [2]
    balooga
    Link
    It's interesting. I think smaller projects might get some value from not needing a build step, but I imagine most teams are still going to want to strip out the type annotations to reduce bundle...

    It's interesting. I think smaller projects might get some value from not needing a build step, but I imagine most teams are still going to want to strip out the type annotations to reduce bundle size anyway. So this wouldn't bring anything you don't already get in TS today.

    1. stu2b50
      Link Parent
      That’s addressed in the blog post It also talks about how this would standardize the typing syntax across tools like flow and typescript, making JS typing as a whole more portable.

      That’s addressed in the blog post

      So when it comes to writing and running code, a developer’s inner-loop would look a little different.

      Today TypeScript goes through a process of compiling from .ts files to .js files, which then run in the browser. Our proposal is to simply have browsers run the input JavaScript code which would support type annotations.

      Meanwhile, writing code and type-checking would stay the same. A developer could get instant type-checking feedback in an editor with TypeScript support, run TypeScript on the command line, and add TypeScript as part of their CI tasks. The biggest difference is that because we would not need a build step, we would dramatically lower the barrier to entry for JavaScript devs to experience the power of types and great tooling.

      It also talks about how this would standardize the typing syntax across tools like flow and typescript, making JS typing as a whole more portable.

      2 votes