DeepSource has joined Harness. Learn more
JavaScript logoJavaScript/
JS-0579

Missing `providedIn` propertyJS-0579

Minor severityMinor
Bug Risk categoryBug Risk
angular

Using the providedIn property makes classes decorated with @Injectable tree shakeable.

If you use providedIn, the injectable is registered as a provider of the module without adding it to the provider list of the module.

Bad Practice

@Injectable()
class Test {}
@Injectable({
    providedIn: 'root'
})
class Test {}

@Injectable({
    providedIn: SomeModule
})
class Test {}