fast icon indicating copy to clipboard operation
fast copied to clipboard

fix: @attr's ValueConverter toView should be conditioned to AttributeMode

Open yinonov opened this issue 3 years ago • 0 comments

🐛 Bug Report

AttributeConfiguration's converter type requires toView & fromView to always be set. @attr mode, when set to a 'fromView' value, will not reflect property assignment to the DOM. this makes ValueConverter's toView property redundant. thus, should not be part of the converter's interface in that scenario.

https://github.com/microsoft/fast/blob/c9bd1b900afa95b47e0f79a6409f256dd2827fdb/packages/web-components/fast-element/src/components/attributes.ts#L5-L22

🤔 Expected Behavior

toView should be omitted from ValueConverter interface if mode of @attr is set to 'fromView'.

😯 Current Behavior

toView is required unconditionally.

💁 Possible Solution

I'm not sure if typescript features a way for interfaces to affect each other conditionally or set different partial interfaces according to what a sibling member of an object is assigned to.

Would gladly PR if pointed to a leading direction...

🔦 Context

it is not a deal breaker and doesn't affect the result of code but pollutes the codebase with a redundant confusing toView member in converters

yinonov avatar Apr 07 '22 06:04 yinonov