Skip to content

Unable to use abstract Type as provider token for inject() function #68

@JanUnld

Description

@JanUnld

During the integration of injection-js into the refactoring of a personal side project, I noticed, that consumers are currently not able to use the (previously introduced) inject() function with abstract types.

A quick look at the source and a comparison with the current implementations of Angular, revealed that the function signature is currently not supporting abstract types.

export function inject<T>(token: Type<T> | InjectionToken<T>): T {

Angulars provider token type is going to add proper support for this. To be more specific, the AbstractType<T> typing below will do so.

export interface AbstractType<T> extends Function {
  prototype: T;
}

I'll be happy to provide a fix PR for it in a little while. Nevertheless, I created this issue for the sake of it.

Best regards ✌

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions