Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Issue 1676463002: Type annotations instead of closure comments. (Closed)

Created:
4 years, 10 months ago by ochafik
Modified:
4 years, 10 months ago
Reviewers:
vsm, Leaf, Jennifer Messerly
CC:
dev-compiler+reviews_dartlang.org
Base URL:
git@github.com:dart-lang/dev_compiler.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Emit TypeScript / Closure ES6_TYPED type annotations in --closure mode (instead of closure comments). - Replaced ClosureType by a general JS.TypeRef, used in AST for identifier types, return types - Convert DartType to JS.TypeRef (in mixin JsTypeRefCodegen), including type parameters (also added to AST in Fun & ClassExpression) - Emit field declarations expected by TS - Wrote a TypeScriptTypePrinter (mixed in by Printer) and a ClosureTypePrinter (might disappear soon) - Simplified annotation code, called in more places (seems to gives more source info) Example input: List/*<T>*/ func/*<T>*/(List/*<T>*/ items, dynamic/*=T*/ seed) {} class Foo<T> { int i; static var x; Foo(this.i, o, {String v : "?"}) {} } Output: function func<T>(items: core.List<T>, seed: T): core.List<T> {} const Foo$ = dart.generic(function(T) { class Foo<T> extends core.Object { i: number; static x; Foo(i: number, o, {v = "?"}: {v?: string} = {}) { this.i = i; } } ... Foo.x = null; return Foo; }); Known remaining issues: - typedefs expect a `type Callback = (...) => ...;` statement - `exports` is a reserved keyword in TS (either we change the way we do exports, or we'll need a different temp + extra type annotations of the default-exported object). - Generic type is currently locked inside the generic call. Might be able to solve by exporting signatures in .d.ts file, or changing the way we do generics. BUG= R=jmesserly@google.com Committed: https://github.com/dart-lang/dev_compiler/commit/2b3823f4a9309c23b0b1d1c0faa31df5f9a24c54

Patch Set 1 : #

Patch Set 2 : fix tests #

Patch Set 3 : #

Total comments: 52

Patch Set 4 : merged master #

Patch Set 5 : addressed some comments #

Patch Set 6 : addressed comments #

Patch Set 7 : addressed more comments #

Patch Set 8 : #

Patch Set 9 : merged master #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1049 lines, -399 lines) Patch
M lib/src/closure/closure_annotation.dart View 5 chunks +36 lines, -24 lines 0 comments Download
M lib/src/closure/closure_annotator.dart View 1 chunk +20 lines, -121 lines 0 comments Download
M lib/src/codegen/js_codegen.dart View 1 2 3 4 5 6 7 8 38 chunks +140 lines, -75 lines 0 comments Download
M lib/src/codegen/js_names.dart View 2 chunks +7 lines, -0 lines 0 comments Download
M lib/src/codegen/js_printer.dart View 1 2 3 4 5 6 1 chunk +3 lines, -1 line 0 comments Download
A lib/src/codegen/js_typeref_codegen.dart View 1 2 3 4 1 chunk +128 lines, -0 lines 0 comments Download
M lib/src/js/js_ast.dart View 1 chunk +3 lines, -2 lines 0 comments Download
A lib/src/js/js_types.dart View 1 2 3 4 5 1 chunk +198 lines, -0 lines 0 comments Download
M lib/src/js/nodes.dart View 1 2 3 4 12 chunks +69 lines, -9 lines 0 comments Download
M lib/src/js/printer.dart View 1 2 3 4 5 6 12 chunks +51 lines, -5 lines 0 comments Download
M lib/src/js/template.dart View 1 2 3 1 chunk +27 lines, -0 lines 0 comments Download
A lib/src/js/type_printer.dart View 1 2 3 4 5 6 1 chunk +226 lines, -0 lines 0 comments Download
M test/closure/closure_annotation_test.dart View 1 2 chunks +18 lines, -17 lines 0 comments Download
M test/codegen/closure.dart View 1 2 3 4 5 6 7 5 chunks +10 lines, -4 lines 0 comments Download
M test/codegen/expect/closure.js View 1 2 3 4 5 6 7 1 chunk +106 lines, -134 lines 0 comments Download
M test/codegen/expect/collection/src/unmodifiable_wrappers.txt View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M test/codegen/expect/collection/src/wrappers.txt View 1 2 3 1 chunk +4 lines, -4 lines 0 comments Download
M test/codegen/expect/map_keys.js.map View 1 chunk +1 line, -1 line 0 comments Download
M test/codegen_test.dart View 1 2 3 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 24 (17 generated)
ochafik
Hi guys, here's a timid attempt to bring TypeScript annotations to our AST. The output ...
4 years, 10 months ago (2016-02-05 22:03:37 UTC) #15
Jennifer Messerly
On 2016/02/05 22:03:37, ochafik wrote: > Hi guys, here's a timid attempt to bring TypeScript ...
4 years, 10 months ago (2016-02-09 00:39:08 UTC) #17
Jennifer Messerly
I'll keep looking at this but wanted to send a few preliminary comments your way. ...
4 years, 10 months ago (2016-02-09 01:21:34 UTC) #18
Jennifer Messerly
Few more comments but LGTM. Since we're split across an ocean figured I'd ask a ...
4 years, 10 months ago (2016-02-09 16:41:58 UTC) #19
Jennifer Messerly
And I'm happy to take another look too if it would be helpful. :)
4 years, 10 months ago (2016-02-09 16:42:54 UTC) #20
ochafik
Thanks a lot John! https://codereview.chromium.org/1676463002/diff/180001/lib/src/js/js_types.dart File lib/src/js/js_types.dart (right): https://codereview.chromium.org/1676463002/diff/180001/lib/src/js/js_types.dart#newcode1 lib/src/js/js_types.dart:1: // Copyright (c) 2012, the ...
4 years, 10 months ago (2016-02-10 18:12:46 UTC) #21
ochafik
4 years, 10 months ago (2016-02-10 18:22:27 UTC) #24
Message was sent while issue was closed.
Committed patchset #9 (id:300001) manually as
2b3823f4a9309c23b0b1d1c0faa31df5f9a24c54 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698