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

Parameter initializers (default values) should be const #368

Open
mhevery opened this issue Apr 26, 2016 · 2 comments
Open

Parameter initializers (default values) should be const #368

mhevery opened this issue Apr 26, 2016 · 2 comments

Comments

@mhevery
Copy link

mhevery commented Apr 26, 2016

  constructor(public path: string, public child: Url = null,
              public auxiliary: Url[] =[],
              public params: {[key: string]: any} =  {}) {}

was:

  Url(this.path, [this.child = null, this.auxiliary = [], this.params = {}]) {}

should be:

  RootUrl(String path,
  Url(this.path, [this.child = null, this.auxiliary = const [], this.params = const {}]) {}
  • const [] instead of []
  • const {} instead of {}
@mhevery
Copy link
Author

mhevery commented Apr 26, 2016

Also:

export const ROUTER_DIRECTIVES: any[] = /*@ts2dart_const*/[RouterOutlet, RouterLink];

creates

final List<dynamic> ROUTER_DIRECTIVES = [RouterOutlet, RouterLink];

missing const

@mprobst
Copy link
Contributor

mprobst commented Apr 26, 2016

This was caused by a confusing versioning issue in npm, but the issue still holds - parameter initializers should always implictly be const.

@mprobst mprobst changed the title Parameters should be const Parameter initializers (default values) should be const Apr 26, 2016
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

2 participants