-
Notifications
You must be signed in to change notification settings - Fork 27.1k
inject of ElementRef does not use generic type for the returned type inference #53894
Copy link
Copy link
Open
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: dicross-cutting: types
Milestone
Description
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Consider the example injection of the ElementRef with a specified generic type:
// OK: hostEl is of type ElementRef<HTMLElement>, as expected
hostElExplicit = inject<ElementRef<HTMLElement>>(ElementRef);
// KO: hostEl is of type ElementRef<any>, expecting ElementRef<HTMLElement>
hostElInfered = inject(ElementRef<HTMLElement>);Ideally inject(ElementRef<HTMLElement>) would have the return type of ElementRef<HTMLElement>.
The fix is likely around the type definition for the ProviderToken.
Please provide a link to a minimal reproduction of the bug
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: coreIssues related to the framework runtimeIssues related to the framework runtimebugcore: dicross-cutting: types