dojo / core

:rocket: Dojo 2 - language helpers and utilities.
http://dojo.io
Other
213 stars 62 forks source link

Adding readonly modifier where appropriate, issue #180 #247

Closed rorticus closed 7 years ago

rorticus commented 7 years ago

Added readonly modifier where I felt it was appropriate. (issue #180)

At first I was adding it to all interfaces where the declared properties where not being written to, but I decided not to do that, so people could still modify objects that they created.

let options: KwArgs {
    year: 2016,
    month: 10
};

if(useLastMonth) {
    options.month = 9;
}

const date = new DateObject(options);

instead of,

let month = 10;
if(useLastMonth) { 
    month = 9;
}

let options: KwArgs {
    year: 2016,
    month
};

const date = new DateObject(options);

Granted, this is a terrible, contrived, example, but you get the idea.

codecov-io commented 7 years ago

Current coverage is 94.42% (diff: 100%)

Merging #247 into master will increase coverage by 0.04%

@@             master       #247   diff @@
==========================================
  Files            47         47          
  Lines          2457       2457          
  Methods          28         28          
  Messages          0          0          
  Branches        464        464          
==========================================
+ Hits           2319       2320     +1   
  Misses           51         51          
+ Partials         87         86     -1   

Powered by Codecov. Last update c1c48f0...c09b863

agubler commented 7 years ago

@rorticus how do we know that this won't break consumers already using this package and updating value we've now declared readonly?

rorticus commented 7 years ago

@agubler , I've tried to leave "public interfaces", where people pass in configuration objects, alone. If you see a place where I missed that constraint, let me know. Most of these changes should just be for internally used interfaces and private variables that hopefully people aren't messing with anyways.