Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deprecated @angular/core/testing's inject()Β #46085

Open
@yjaaidi

Description

@yjaaidi

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Hey πŸ‘‹ !

There are currently two inject() functions that have two completely distinct purposes and signatures: @angular/cores and @angular/core/testing's.

This can be misleading and harm the Developer eXperience. (I already had some trouble with IDEs preferring to automatically import @angular/core/testing instead of @angular/core.)

πŸ€” This reminds me of async => waitForAsync renaming

Proposed solution

IMO, @angular/core/testing's inject() is not widely used and we could simply deprecate before we remove it in a future version. We could also ship a migration schematic that "simply" replaces:

inject([A, B], (a, b) => {...})

with

(a = inject(A), b = inject(B)) => {...}

Alternatives considered

Rename @angular/core/testing's inject() to something else... maybe nostalgicInject()

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: testingIssues related to Angular testing features, such as TestBed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions