fix(spectator): make mock template type safe (#607)#609
fix(spectator): make mock template type safe (#607)#609szabyg wants to merge 1 commit intongneat:masterfrom
Conversation
|
|
BREAKING CHANGE: introducing type safety for the template values in createSpyObject and mockProvider. This might cause breaking builds because the compiler will find issues hidden until now.
|
@NetanelBasal Am I supposed to check all PR checklist items (even if they are IMO not relevant) or only the ones that I think are relevant? This PR fixes a bug (sort of) and helps improving code quality. I don't see the need for an additional unit test or documentation, other than the release note explanation of why this is a breaking change. |
|
I'd love to see basic types test. You can use the same library I'm using here |
|
@NetanelBasal Interesting idea and testing library. We spent some hours now to try to find a way to add a meaningful test without testing the type of something that's part of the test itself. On the other hand, the point of the actual change is that the compiler will throw an error if the template type for the provider doesn't match the provider type. Trying the following things: This would be nice but it doesn't work: Or this but Would you have a hint what else I could try? Otherwise I suggest taking it as is, the compiler does complain and that's the point, isn't it? |
|
Any ideas/update on this? |
BREAKING CHANGE: introducing type safety for the template values in createSpyObject and mockProvider. This might cause breaking builds because the compiler will find issues hidden until now.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Weak type checking when mocking services, only checking the template keys, not the values types.
Issue Number: #607
What is the new behavior?
The TS compiler will show up mismatches between the service template values and the actual service methods.
Does this PR introduce a breaking change?
Introducing type safety for the template values in createSpyObject and mockProvider. This might cause breaking builds
because the compiler will find issues hidden until now.
Other information