Feature/#703 typed injectiontokens #704
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New Pull Request
Closes #703
Prerequisites
Please make sure you can check the following boxes:
Type(s) of Changes
Contribution Type
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Description
This adds new
InjectionToken
constants topiral-ng
and additionally registers the known services using these tokens.This improves compatibility with Angular's
inject
function.Remarks
I've written this PR without actually being a consumer of this project. So my understanding of it is limited.
Existing tests: on my system some tests have failed before the change, still failing after the change:
New tests: Setting up an automated test for
piral-ng
is currently beyond my scope / understanding of this project.A reasonable test (be it manual or automated) would ensure:
inject
survives the type check (in contrast to the existing string based tokens)inject
or@Inject
really leads to injection of the servicesInjection token types: I'm also a bit unsure about the typing of the
PROPS
token. Currently it'sInjectionToken<any>
.Without much experience in this project, it seems to me that almost anything can be passed here. Perhaps
any
can be improved toRecord<string, any>
or something similar but a simpleany
should make sure the consumer can just write down their own props type on the@Inject
-decorated parameter /inject
-assigned field.Injection token names:: I've reproduced the original service names (uppercase) to name the exported injection token constants. The names passed to the
InjectionToken
constructor are just for debugging purposes.Feel free to edit anything in this PR.