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
There is no type error if I try to call it with following token:
consttoken=newInjectionToken<string>('');
Proposition
This happens because <T> in InjectionToken is only used inside factory function that you can pass inside constructor. I suggest we add a dummy prop inside InjectionToken class to protect against this issue:
/** @internal */privatereadonly_guard!: T;
Please provide a link to a minimal reproduction of the bug
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
No
Description
Issue
I have made a function that expects a particular value from DI, say:
There is no type error if I try to call it with following token:
Proposition
This happens because
<T>
inInjectionToken
is only used inside factory function that you can pass inside constructor. I suggest we add a dummy prop insideInjectionToken
class to protect against this issue:Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-crs76u
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: