News for hackers. Stuff that matters.
Re:Flow vs. Typescript by dtech on Monday June 06, 2016 @03:02AM (#11845110)
No. With flow you can do both:

    var x /*: string*/ = ""
    var x : string = ""
With TS you can only do the latter. The first one has the advantage that it's legal Javascript, thus not requiring a compiler. Since typescript is set-up purely as a compiler anyway I'm not sure it would be a useful feature for them.

A disadvantage could be that it's easier to make silent errors by making syntax errors in the comments. I don't how Flow would handle e.g.

    `var x /* number*/ = ""`
Re:Flow vs. Typescript by joshuacc on Monday June 06, 2016 @09:47AM (#11846695)
That's not entirely accurate. TypeScript 1.8 added the ability to use type information from JSDoc-style comments.

For example:

    /**
     * @param {string} a
     * @param {number} b
     * @returns {string}
     */
    function foo(a, b){
      return a + b;
    }
Is functionally identical to:

    function foo(a: string, b: number): string {
      return a + b;
    }
See: https://github.com/Microsoft/TypeScript/issues/4790
Re:Flow vs. Typescript by Arnavion on Monday June 06, 2016 @01:49PM (#11848712)
Not equivalent - the TS compiler currently does not actually enforce the types in a JS file. See https://github.com/Microsoft/TypeScript/issues/4790#issuecom... The feature of parsing JSDoc comments is currently only used for providing completion info for JS editors and for consuming exported JS functions and variables in TS files.
Re:Flow vs. Typescript by joshuacc on Tuesday June 07, 2016 @03:32PM (#11857110)
Ah, you're right. Looks like I'd misunderstood the scope of that change.
Re:Flow vs. Typescript by abritinthebay on Monday June 06, 2016 @02:36PM (#11849111)
"functionally" identical to the type checker.

But not functionally identical when it involves my fingers typing (the function there being my ergonomics). Flow would just be inline comments at the code points required.