4 ms·
> This proposal aims to enable developers to add type annotations to their JavaScript code, allowing those annotations to be checked by a type checker that is e
by spankalee 2y ago
> This proposal aims to enable developers to add type annotations to their JavaScript code, allowing those annotations to be checked by a type checker that is external to JavaScript. At runtime, a JavaScript engine ignores them, treating the types as comments.
- dgellow 2y agoYes, that’s explaining what type erasure is. “type as comments” is what Flow supports, literal comments for type annotations. I think we disagree on the terminology but agree on the goal of the proposal
- eyelidlessness 2y agoThe proposal would explicitly treat supported type annotation syntax as comments in the grammar. It is definitely types as comments, even if it is also type erasure. And it would apply to Flow’s type annotation syntax which is also not presently treated as comments, at least for the very large subset of that syntax which overlaps with the proposal.
- dgellow 2y agoI meant https://flow.org/en/docs/types/comments/ https://flow.org/en/docs/types/comments/
- eyelidlessness 2y agoI know what you meant.
- pcthrowaway 2y agoTypes as comments is what jsdoc supports. Flow is compiled like typescript. tsc does also support jsdoc though, so technically I think tsc is closer to supporting types as comments, though it's possible Flow has this also.
- spankalee 2y agoTypes _in_ comments is different from types _as_ comments. "Types as comments" refers to how type expressions are parsed.
- pcthrowaway 2y agojsdoc is a format for supplying types (and annotations) as comments as well. I think I get the distinction you're trying to make, but I don't think the nuance there is significant enough to merit differentiating the two.
- dgellow 2y agohttps://flow.org/en/docs/types/comments/ https://flow.org/en/docs/types/comments/
- pcthrowaway 2y agoThanks, I've never used flow and didn't know this. I've only seen it used in the non-comment form.
- spankalee 2y ago"types as comments" is the term that the champions and reviewers of this proposal have been using. It refers to how the types are parsed: aside from some kind of standard start and end delimiters, the parser does not try to parse the expression-level type syntax. Type expressions are just strings of characters. This way you can have basically any syntax at all for types.
- deleted 2y ago[deleted]