Hacker News new | past | comments | ask | show | jobs | submit login

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



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.


Ah, you're right. Looks like I'd misunderstood the scope of that change.


"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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: