Buslowicz / twc

TypeScript based, boilerplate-less, Polymer toolbox friendly Polymer Modules
32 stars 1 forks source link

Handle observer when property isn't declare in properties #54

Closed tpluscode closed 7 years ago

tpluscode commented 7 years ago

The @observe decorator throws on this line when you define an element as shown below because obserever property cannot be found in.

export class ObserveMissing {
   @observe
   someObserver(noSuchProp) {
   }
}

I was about to create a PR for this by simply throwing a more helpful error but I think that it's not actually correct. After all, it is also possible to observe properties only ever declared in the template. Such that never appear in properties: {}.

In this case the observer should be added to observers:

Polymer({
   observers: [
      'someObserver(noSuchProp)'
   ]
});
tpluscode commented 7 years ago

I'd like to contribute a test case although I'm not sure whether to add a test to module.test.ts or maybe annotations could be tested in isolation?