@bakkot Thanks for your reply! As to those issues, I'm aware of many of those, and have proposed and contributed to some of them.
I think most of those proposals, including past proposals, suffer from trying to work backwards from TypeScript, to some degree, and aren't really general-purpose.
In other words, many start with assumptions like:
- wanting to put
:
to assign a type - even though TypeScript or other type systems work "okay-ish" with this syntax, it has specific places where it conflicts with JavaScript, where :
is already used to assign a value
- generally keeping the same "order" of type annotations that TypeScript has established
That's why I'm proposing the inverse - coming up with a general hash-comment syntax with some simple parsing rules, and then proving out that it can annotate ergonomically and expressively enough to establish type- and type-aware features.
I don't disagree that such a proposal (like @conartist6 alluded to) would be less attractive to TypeScript the more that it would deviate from TypeScript, but I think matching TypeScript as closely as possible shoudl be a non-goal. The goal (IMO) should be to have an ergonomic comment syntax that can be less verbose than wrapping in /*
*/
, and has comment-end logic that isn't just "end of line" like //
.
So, I think what everyone is circling around doesn't really have to do with types at all, and even Microsoft's proposal doesn't make that clear. What people are circling around is that the utility of JavaScript's comment syntax is limited and un-ergonomic for specific use-cases, enough that new languages are developed with new syntax rather than leveraging a special "comment form" that can ergonomically annotate markers that a meta-language might want to use. JSDoc is the current solution for that, but it's extremely verbose, and of course becomes very unwieldy when working with function generics or non-null assertions.
So, that's what I'm proposing here - which I could also make more clear - an additional comment form that is both flexible for very long "chunks" of annotations, but also can "auto-close" with some basic rules. And is less weird than a proposal like ::
(which exists to make forms like :: string
even if ::
doesn't really make sense, semantically, with JavaScript. JavaScript already has "hashbang comments", where #!
is already a comment start, so starting with #
(or using #{special_character}
) as a generalized form is treading less on new territory.
Another reason I didn't add to that repo in the form of a new issue is that the proposal owners thus far have shown little interest in looking at anything that deviates from TypeScript, so I just fundamentally feel like that proposal itself is a dead-end.
@bakkot EDIT: it looks like you're someone else who put a lot of thought into alternate syntax forms, so I'd be happy to explore some variations of hash comment syntax with you.