You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior:
should work as before upgrade, I can use the value as input in html. Laurence Mercer (@input) can be above a get method or above a set method. and get/set method can appear in the class in each place.
Actual behavior:
get an error: Can't bind to 'value' since it isn't a known property of 'some-componnet'. Laurence Mercer (@input) must be in the get method, but get method must appears before the set method.
this code works: but for me it is workaround:
Code1 failed:
private _value:string;//I change order of the get to be before the set
@Input()getvalue(){returnthis._value;}setvalue(value: string){this._value=value;}
Code2 failed:
private _value:string;//I remove annotation from the set method and put above the get
@Input()getvalue(){returnthis._value;}setvalue(value: string){this._value=value;}
declarevarInput: any;classA{
@Input()setvalue(value: string){}// worksgetvalue(){return"";}}classB{setvalue(value: string){}
@Input()getvalue(){return"";}// does not work}
It looks like decorators on the second declaration are not emitted.
Brachi Packter (@brachi-wernick) the fix should be in typescript@next later tonight. please give it a try and let us know if you are still running into issues.
declare var Input: any;
class A {
set value(value: string) { }
@Input() get value() { return ""; } // fixed, works now
}
class B {
get value() { return ""; } // still doesn't work
@Input() set value(value: string) { }
}
Something interesting is that I get an empty array for the design:paramtypes key when the getter is decorated, but a singleton array if the setter is. In 2.0.8, there is no emit for that key. Is this a new feature? Just curious.
Aluan Haddad (@aluanhaddad) As getters cannot have parameters, the design:paramtypes metadata should always be for the setter, if it has one. It looks like this is a bug in 2.0.8 and in 2.1.
Activity
mhegazy commentedon Dec 7, 2016
Brachi Packter (@brachi-wernick) can you share more context? i can not piece together a self-contained repro using your snippets.
rbuckton commentedon Dec 7, 2016
Mohamed Hegazy (@mhegazy) Here's a simple repro:
It looks like decorators on the second declaration are not emitted.
mhegazy commentedon Dec 8, 2016
Brachi Packter (@brachi-wernick) the fix should be in
typescript@nextlater tonight. please give it a try and let us know if you are still running into issues.brachi-wernick commentedon Dec 8, 2016
Mohamed Hegazy (@mhegazy) I checked the latest in that is what I found:
aluanhaddad commentedon Dec 8, 2016
Mohamed Hegazy (@mhegazy) It is working for me with typescript@2.2.0-dev.20161208
Brachi Packter (@brachi-wernick)
@latestis the latest release.aluanhaddad commentedon Dec 8, 2016
Something interesting is that I get an empty array for the
design:paramtypeskey when the getter is decorated, but a singleton array if the setter is. In 2.0.8, there is no emit for that key. Is this a new feature? Just curious.rbuckton commentedon Dec 9, 2016
Aluan Haddad (@aluanhaddad) As getters cannot have parameters, the
design:paramtypesmetadata should always be for the setter, if it has one. It looks like this is a bug in 2.0.8 and in 2.1.