dart-archive / ts2dart

ts2dart TypeScript to Dart transpiler
Apache License 2.0
181 stars 62 forks source link

support function types #358

Closed mhevery closed 8 years ago

mhevery commented 8 years ago

Given:

  method(fn: (V, K) => void) { ... }

Expected:

  method(void fn(V arg0, K arg1)) { ... }

Actual:

  method(dynamic /* (V, K) => void */ fn) { ... }

/cc: @vsmenon

mprobst commented 8 years ago

How does this interact with generic method types? Maybe this?

f/*<A, B>*/(dynamic/*=B*/ fn(dynamic/*=A*/ a)) {}

How does this look for recursive types function typed arguments, e.g. functions that take functions that take functions?

vsmenon commented 8 years ago

That looks correct on generics.

Here's an example with function typed arguments:

void foo(String bar(String baz())) {
  var result = bar(() => "hello");
  print(result);
}