-
Notifications
You must be signed in to change notification settings - Fork 434
[discussion] Add LifecycleHook interface definition #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@CarterLi I definitely think this should be added; however, I disagree with adding all of them in one interface. The reason Angular has all the
So, why would we choose to not use TypeScripts' types? Especially, when that's the main reason people use TypeScript. |
I doubt this approach is useful because it is completely optional. Developers probably forget to add such interface and just declare hooks without it. |
It's a common approach in Vue, for example DirectiveOptions: export interface DirectiveOptions {
bind?: DirectiveFunction;
inserted?: DirectiveFunction;
update?: DirectiveFunction;
componentUpdated?: DirectiveFunction;
unbind?: DirectiveFunction;
} In my opinion those interfaces are very useful because they enable intellisense of IDEs, which generally increases coding speed and reduces chances of typos. |
That makes sense. Probably it would be better to augment |
Inspired by Angular lifecycle hook interfaces.
Instead of define every hook method in separated interfaces, I prefer defining them in one interface in order not to introduce redundant
implement OnXxx
s. But at the same time as all of those methods are optional, it generally disables the strict type checking, which makes it mainly for IDE's intellisense.The text was updated successfully, but these errors were encountered: