Skip to content

Component inheritance and @ViewChildren or @ContentChildren: "Uncaught Error: useExisting is unimplemented" #219

@giancarlo-dm

Description

@giancarlo-dm

Hello,

First I appreciate the hardwork you guys had put on this project.

The problem:

I was trying to implement a use case similar to this stackoverflow question, but when I tried to use the provider declaration: providers: [{provide: BaseComponent, useExisting: forwardRef(() => ChildComponent2) }], I got the following error on the console:

Uncaught Error: useExisting is unimplemented
    at resolveReflectiveProvider (modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62054)
    at modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62121
    at Array.forEach (<anonymous>)
    at Object._normalizeProviders (modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62111)
    at _bundleComponent (modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62379)
    at modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62402
    at Array.forEach (<anonymous>)
    at bundle (modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62401)
    at modules.js?hash=30556e0263a3949b7bc00058f573ce0b4384bd92:62429
    at Array.forEach (<anonymous>)

So I browsered the source code and found this at src/core/di/reflective_provider.ts:

if (provider.useExisting) {
    const [name,value] = provide( provider.useExisting );
    const method = 'factory';

    throw new Error('useExisting is unimplemented');
    // target = (v) => v;
    // annotate(target, 'factory', {name});
    // annotate(target, 'inject', [toInjectorName(provider.useExisting)]);
  }

The questions:

Was it too hard to backport this functionality or it was just forgotten to implement?

Is there an workaround (or correct way of doing this), that is similar to the stackoverflow example I gave?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions