Skip to main content

Function: normalizeProvider()

normalizeProvider<T>(provider): object

Normalizes a provider definition into a standard object shape.

  • If given a class constructor, returns { provide, useClass }.
  • If given a Provider object, returns it unchanged.

This ensures downstream logic can uniformly handle providers.

Type Parameters

T

T = unknown

The type provided by this provider.

Parameters

provider

Provider<T>

A class constructor or a Provider object.

Returns

object

An object with explicit provide, and either useClass or useValue.

provide

provide: Token<T>

useClass?

optional useClass: Type<T>

useValue?

optional useValue: T