Force generic type for ElementRef #1463
Closed
dkimmich-onventis
started this conversation in
New Rule Proposals
Replies: 1 comment
-
This can be achieved in a more generic way by using TypeScript ESLint's |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
ElementRef is a concept that may be used occasionally in applications. It has a generic type which defaults to
any
. In most casesElementRef
is used to work with the JavaScript APIs of an HTML element. However because the generic type defaults toany
, there is no typing of these APIs by default. So I have seen myself writing code such as:This is bad practice, instead I should use the generic type of the
ElementRef
:My proposal is to add a rule which throws a lint error when no generic type is used on
ElementRef
. In cases where it does not make sense to specify a generic type,ElementRef<any>
should be valid.Beta Was this translation helpful? Give feedback.
All reactions