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*/ = ""`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/4790Not 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.
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.
Can't you do the same thing with TypeScript's typings?