-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Improve TestModuleMetadata typings #37178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Update TestModuleMetadata typings to be stricter and in-line with NgModule interface typings. Issue Close angular#37178
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage. We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package. You can find more details about the feature request process in our documentation. |
To improve compiler errors on `TestModuleMetadata`, lets replace `any` for `providers`, `declarations` and `imports` fixes angular#37178
Uh oh!
There was an error while loading. Please reload this page.
🚀 feature request
Relevant Package
This feature request is for @angular/core
Description
Typings for
TestModuleMetadata
are too loose and they do not provide proper type-checking. Ths can lead to hard-to-track bugs in tests in case there is a typo or some other error inTestBed
configuration object.Example issue:
If
SomeService
is decorated as@Injectable({ providedIn: 'root' })
, the test for the above TestBed configuration will actually create an instance ofSomeService
instead ofSomeServiceMock
because there is a typo (provibe
instead ofprovide
) in the provider so this provider is basically ignored. This kind of an error can be hard to pin down and could be easily caught by stricter typings forTestModuleMetadata
.Describe the solution you'd like
I suggest updating typings of
TestModuleMetadata
to match the typings ofNgModule
interface. Please check the related PR I created.Describe alternatives you've considered
Alternative solution is to explicitly type the providers yourself:
The text was updated successfully, but these errors were encountered: