ericmckean / traceur-compiler

Automatically exported from code.google.com/p/traceur-compiler
Apache License 2.0
0 stars 0 forks source link

Option to preserve comments #203

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
To make traceur useful for scripts that uses Closure Compiler JSDoc type 
annotations it seems important to allow us to keep comments and even generate 
comments.

Original issue reported on code.google.com by arv@chromium.org on 19 Feb 2013 at 11:16

GoogleCodeExporter commented 9 years ago
Continuing the conversation from

  https://codereview.appspot.com/7487046/

> Peter was adding TypeScript type annotation and he was going to add a
> static type check pass. Adding runtime asserts is another option. I
> also think those are valuable to be able to turn on for debug mode.

If the JSDoc annotations were preserved in the traceur output, would
Closure Compiler give us a typechecker for free?

Original comment by usrbi...@yahoo.com on 21 Mar 2013 at 8:58

GoogleCodeExporter commented 9 years ago
Not for free. We would have to add some annotations because we don't put
@constructor nor @extends in comments since those are all in the source now.

Original comment by arv@chromium.org on 21 Mar 2013 at 9:11

GoogleCodeExporter commented 9 years ago
There are a lot of lessons that can be learned from the JsCompiler type system. 
Check out the TypeScript type system by comparison. Emitting JsDoc type 
annotations is not a great long term strategy.

Original comment by peter...@google.com on 21 Mar 2013 at 9:19

GoogleCodeExporter commented 9 years ago
I looked over TypeScript briefly (the repo, the website, the community),
and I have to say, it was very educational. Microsoft definitely has a
certain flavor, and it comes through strongly in everything they do.

  In a hurry, so I'll touch on that later.

I didn't have a chance yet to test out the typechecking of TypeScript,
but just looking over the syntax, it's more expressive than Closure
Compiler's type declaration syntax (you can declare functions taking
function parameters -- that in turn take certain parameters).

I agree that magic comments are not very satisfying to use, but in terms
of functionality, it seems like they should theoretically be equivalent.

What's your take on the type-checking ability of Closure compiler vs
TypeScript? I assume it's more a function of specific implementations as
opposed to the choice of using JSDoc vs syntax?

I notice that TypeScript also supports JSDoc. I didn't look too closely
into how that interacts with their native type annotations.

I do like the 'var x: type' style of type declaration; it's a lot less
fiddly to parse. I kind of wish C used that style.

Original comment by usrbi...@yahoo.com on 22 Mar 2013 at 9:04