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
I'm not sure if this is 100% correct, since I don't recall seeing it anywhere else, but in our Angular project, we are marking all @Output fields readonly because really, there is no need to ever re-assign them.
Unless there are some edge cases, which we aren't aware of right now, it would be great if codelyzer could do the check, if all @Output fields are marked as readonly for us, otherwise we always need to check for it manually in code reviews.
Similarly it could be also checked that @Input is never marked as readonly (I have seen it sometimes in our code base and typescript never complained about it, even though it was definitely wrong and set at a later point).
I've never implemented a tslint rule myself, but if you think this one makes sense and you know of some which I could basically copy/paste with few adjustments, to achieve those checks, I'd be fine with contributing the rule as well.
The text was updated successfully, but these errors were encountered:
Well basically, I'd love to use https://www.npmjs.com/package/tslint-immutable - but we're not quite there yet unfortunately, that's why we started just to enforce readonly markings on anything we don't intend to change, which are mostly Observables, just to prevent if somebody unfamiliar with observables might assign a new value to a field, instead of emitting a new value.
Those issues already happened, and that's just why we're trying to mark fields like that as readonly.
I don't see the link between immutable and @output. Your problematic seems to be specific. I'm not sure that this proposal has its place in Codelyzer but let's see other opinions.
I'm not sure if this is 100% correct, since I don't recall seeing it anywhere else, but in our Angular project, we are marking all
@Output
fieldsreadonly
because really, there is no need to ever re-assign them.Unless there are some edge cases, which we aren't aware of right now, it would be great if codelyzer could do the check, if all
@Output
fields are marked asreadonly
for us, otherwise we always need to check for it manually in code reviews.Similarly it could be also checked that
@Input
is never marked asreadonly
(I have seen it sometimes in our code base and typescript never complained about it, even though it was definitely wrong and set at a later point).I've never implemented a tslint rule myself, but if you think this one makes sense and you know of some which I could basically copy/paste with few adjustments, to achieve those checks, I'd be fine with contributing the rule as well.
The text was updated successfully, but these errors were encountered: