Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Move all root-level executable javascript into main #342

Open
DavidSouther opened this issue Feb 12, 2016 · 0 comments
Open

Move all root-level executable javascript into main #342

DavidSouther opened this issue Feb 12, 2016 · 0 comments

Comments

@DavidSouther
Copy link

Dart will not compile executable code left in the root of a document. To match semantics with Dart, it would be nice if ts2dart moved all root executable lines into a main(){} function.

Example:

class angular {
    static bootstrap(root: Node, m: string[]) {}
}

class App {
    static module = { name: "app"};
}

angular.bootstrap(document, [App.module.name]);

After passing through ts2dart becomes (edited for readability):

var document = 'foo' ;
class angular {
  static bootstrap( String s , List < String > m ) { }
}

class App {
  static var module = {
    "name": "App"
  };
}

angular . bootstrap ( document , [ App . module . name ] ) ;

The last line calling angular.bootstrap throws several compiler warning in Dart, as Dart expects this to be a declaration, not an invocation. If ts2dart put that in a main(){}, that would be a Good Thing(tm).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant