Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: NG2016 reported incorrectly for package libraries #48152

Closed
kukjevov opened this issue Nov 21, 2022 · 2 comments
Closed

BUG: NG2016 reported incorrectly for package libraries #48152

kukjevov opened this issue Nov 21, 2022 · 2 comments
Labels
area: compiler Issues related to `ngc`, Angular's template compiler P2 The issue is important to a large percentage of users, with a workaround state: has PR
Milestone

Comments

@kukjevov
Copy link
Contributor

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

Event though declared as breaking change, it should not mean, that valid code should be also reported as bug.

The injectable SomeService inherits its constructor from RESTClient, but the latter has a constructor parameter that is not compatible with dependency injection. Either add an explicit constructor to SomeService or change RESTClient's constructor to use parameters that are valid for DI.

Base class has @Injectable and also is using InjectionToken for each constructor parameter that is not compatible with dependency injection.

If i copy base class into project everything works fine, but if base class with parameters using InjectionToken is declared in package library and used as dependency, this error is reported.

https://github.com/ressurectit/ng-rest/blob/13.0/src/rest/common.ts#L38

I can also provide full reproduction steps easily.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Node: 16.15.0
OS: Windows 10
Angular: 15

Anything else?

No response

@JoostK JoostK added area: compiler Issues related to `ngc`, Angular's template compiler P2 The issue is important to a large percentage of users, with a workaround labels Nov 21, 2022
@ngbot ngbot bot modified the milestone: Backlog Nov 21, 2022
JoostK added a commit to JoostK/angular that referenced this issue Nov 21, 2022
…a library

The stricter checks under `strictInjectionParameters` in Angular 15 now enforce that
an inherited constructor must be compatible with DI, based on whether all parameters
are valid injection tokens. There is an issue when the constructor is inherited from
a class in a declaration file though, as information on the usage of `@Inject()` is
not present within a declaration file. This means that this stricter check cannot be
accurately performed, resulting in false positives.

This commit disables the stricter check to behave the same as it did prior to
Angular 15, therefore avoiding the false positive.

Fixes angular#48152
@JoostK
Copy link
Member

JoostK commented Nov 21, 2022

Thanks for the report, this is indeed an oversight.

@kukjevov kukjevov changed the title BUG: NG2016 reported incorrectly reported for package libraries BUG: NG2016 reported incorrectly for package libraries Nov 22, 2022
dylhunn pushed a commit that referenced this issue Nov 23, 2022
…a library (#48156)

The stricter checks under `strictInjectionParameters` in Angular 15 now enforce that
an inherited constructor must be compatible with DI, based on whether all parameters
are valid injection tokens. There is an issue when the constructor is inherited from
a class in a declaration file though, as information on the usage of `@Inject()` is
not present within a declaration file. This means that this stricter check cannot be
accurately performed, resulting in false positives.

This commit disables the stricter check to behave the same as it did prior to
Angular 15, therefore avoiding the false positive.

Fixes #48152

PR Close #48156
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 24, 2022
trekladyone pushed a commit to trekladyone/angular that referenced this issue Feb 1, 2023
…a library (angular#48156)

The stricter checks under `strictInjectionParameters` in Angular 15 now enforce that
an inherited constructor must be compatible with DI, based on whether all parameters
are valid injection tokens. There is an issue when the constructor is inherited from
a class in a declaration file though, as information on the usage of `@Inject()` is
not present within a declaration file. This means that this stricter check cannot be
accurately performed, resulting in false positives.

This commit disables the stricter check to behave the same as it did prior to
Angular 15, therefore avoiding the false positive.

Fixes angular#48152

PR Close angular#48156
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: compiler Issues related to `ngc`, Angular's template compiler P2 The issue is important to a large percentage of users, with a workaround state: has PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants