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

Move all root-level executable javascript into main #342

@DavidSouther

Description

@DavidSouther

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions