Skip to content

BUG: InjectionToken is not assignable to ViewChildren or ContentChildrenΒ #21152

@kukjevov

Description

@kukjevov

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

If i have InjectionToken i cant assign it to ViewChildren or ContentChildren as mentioned in #12758 Maybe due to changes of Typescript.

Expected behavior

This code is working if you type it to <any> but without it cant be compiled using typescript.

Minimal reproduction of the problem with instructions

This will not compile :).

export const SomeClassToken = new InjectionToken<SomeClass>('SomeClassToken');

export class TestClass
{
    @ViewChildren(SomeClassToken)
    public children: QueryList<SomeClass>;
}

What is the motivation / use case for changing the behavior?

It should compile, because it works if typed to <any>.

Environment


Angular version: 5.1.2


Browser:
During compilation
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Typescript version: 2.5.3
- Node version: 8.1.2  
- Platform:  Windows 

Others:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions