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 had recently made a discussion about a way of specifying that a directive should be typed properly. But I learned that typing's for value in directives are already supported. But modifiers and arg should also be supported as well. With that being said, here are the new typing's for Directives.
The reason I decided to do this is so that directives can be useable. Without good TS support, function refs would have to be used for what directives are meant for. While function refs are good and do the same thing, most of the time, directives are more powerful and allow you it's user to do clean up.
The types above are what are needed to support typed directives. I believe people will use modifiers more than Args. I think it's up to you to decide which is better. Args are generally used to make a completely different thing happen inside a directive. While modifiers are used to change what happens in a directive.
P.S
I don't know how Volar works behind the scenes so I guess this is the best I could do to help. This discussion is mostly a reminder.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Typing Directives Properly
Motivation
I had recently made a discussion about a way of specifying that a directive should be typed properly. But I learned that typing's for value in directives are already supported. But modifiers and arg should also be supported as well. With that being said, here are the new typing's for Directives.
The reason I decided to do this is so that directives can be useable. Without good TS support, function refs would have to be used for what directives are meant for. While function refs are good and do the same thing, most of the time, directives are more powerful and allow you it's user to do clean up.
API Design
Directive Binding
Directive Hook
Function Directive
The types above are what are needed to support typed directives. I believe people will use modifiers more than Args. I think it's up to you to decide which is better. Args are generally used to make a completely different thing happen inside a directive. While modifiers are used to change what happens in a directive.
P.S
I don't know how Volar works behind the scenes so I guess this is the best I could do to help. This discussion is mostly a reminder.
Beta Was this translation helpful? Give feedback.
All reactions