refactor(core): remove duplicate stringify (#53751)

`throwProviderNotFoundError` already stringifies for error. Also let's restrain the paramter type.

PR Close #53751
This commit is contained in:
Matthieu Riegler 2024-01-03 00:14:49 +01:00 committed by Andrew Scott
parent ce41575e34
commit 4cb4e984fb
2 changed files with 4 additions and 2 deletions

View file

@ -59,7 +59,7 @@ export function injectRootLimpMode<T>(
}
if (flags & InjectFlags.Optional) return null;
if (notFoundValue !== undefined) return notFoundValue;
throwProviderNotFoundError(stringify(token), 'Injector');
throwProviderNotFoundError(token, 'Injector');
}

View file

@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import type {ProviderToken} from '../di';
import {isEnvironmentProviders} from '../di/interface/provider';
import {RuntimeError, RuntimeErrorCode} from '../errors';
import {Type} from '../interface/type';
@ -50,7 +51,8 @@ export function throwInvalidProviderError(
/** Throws an error when a token is not found in DI. */
export function throwProviderNotFoundError(token: any, injectorName?: string): never {
export function throwProviderNotFoundError(
token: ProviderToken<unknown>, injectorName?: string): never {
const errorMessage = ngDevMode &&
`No provider for ${stringifyForError(token)} found${
injectorName ? ` in ${injectorName}` : ''}`;