mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 05:13:29 +00:00
[AC-2329] [BEEEP] Use safeProvider in desktop services module (#8457)
This commit is contained in:
@@ -74,6 +74,17 @@ type SafeExistingProvider<
|
||||
useExisting: I;
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a dependency where there is no abstract token, the token is the implementation
|
||||
*/
|
||||
type SafeConcreteProvider<
|
||||
I extends Constructor<any>,
|
||||
D extends MapParametersToDeps<ConstructorParameters<I>>,
|
||||
> = {
|
||||
provide: I;
|
||||
deps: D;
|
||||
};
|
||||
|
||||
/**
|
||||
* A factory function that creates a provider for the ngModule providers array.
|
||||
* This guarantees type safety for your provider definition. It does nothing at runtime.
|
||||
@@ -97,11 +108,15 @@ export const safeProvider = <
|
||||
IExisting extends
|
||||
| Constructor<ProviderInstanceType<AExisting>>
|
||||
| AbstractConstructor<ProviderInstanceType<AExisting>>,
|
||||
// types for no token
|
||||
IConcrete extends Constructor<any>,
|
||||
DConcrete extends MapParametersToDeps<ConstructorParameters<IConcrete>>,
|
||||
>(
|
||||
provider:
|
||||
| SafeClassProvider<AClass, IClass, DClass>
|
||||
| SafeValueProvider<AValue, VValue>
|
||||
| SafeFactoryProvider<AFactory, IFactory, DFactory>
|
||||
| SafeExistingProvider<AExisting, IExisting>
|
||||
| SafeConcreteProvider<IConcrete, DConcrete>
|
||||
| Constructor<unknown>,
|
||||
): SafeProvider => provider as SafeProvider;
|
||||
|
||||
Reference in New Issue
Block a user