3 ms·
This has been proposed for several years now, but there's been very little progress on it: https://github.com/tc39/proposal-type-annotations https://github.com
by mythz 2y ago
This has been proposed for several years now, but there's been very little progress on it:
https://github.com/tc39/proposal-type-annotations https://github.com/tc39/proposal-type-annotations
- spankalee 2y agoThat is "types as comments", not standardizing TypeScript.
- dgellow 2y agoIt is explicitly not type as comments, it is type erasure
- 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]
- crabmusket 2y agoThat has no bearing on the comment you're replying to. The point is that the types could be TypeScript, Flow, Hegel, or something else. The browser won't perform type checking, it will just ignore the types. So, it is not standardising TypeScript.
- jraph 2y agoI believe you and several of your child comments might be confusing "types as comments" with "types in comments".
- madeofpalk 2y agoIt explicitly is, from the link > At runtime, a JavaScript engine ignores them, treating the types as comments. The phrasing here is that the types are meaningless. They are just "comments" to the JS engine.