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

Breaking typed testbed get #30066

Closed
wants to merge 2 commits into from
Closed

Breaking typed testbed get #30066

wants to merge 2 commits into from

Conversation

Goodwine
Copy link

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

TestBed.get returns any
TestBed.typedGet returns T
Injector.get for things not matching Type<T>|InjectionToken<T> return any

Issue Number: N/A

What is the new behavior?

TestBed.get returns T (copy of TestBed.typedGet)
TestBed.typedGet is deprecated
Injector.get also matches TestBed.get signature (i.e. now accepts AbstractType<T>) and the deprecated signature has been deleted.

String providers are no longer supported by the signature and need to be casted to any or migrated to an InjectionToken

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This is supposed to follow after PR #30036, and this should be merged for 9.x assuming the mentioned PR was merged on 8.x

`TestBed.typedGet` is a non breaking change to make way for a typed
`TestBed.get` signature. This commit adds the function with a different
name and strong types.

A future commit for Angular 9.x will replace the current `TestBed.get`
signature with the one added here, and `TestBed.typedGet` will be then
marked as deprecated to be completly removed on Angular 10.x

`Injector.get` will match the same signature as `TestBed.typedGet` on
Angular 9.x, both being breaking changes added at the same time.

Issue #26491
Fixes #29905
@Goodwine
Copy link
Author

@vikerman FYI

@benlesh benlesh added the area: testing Issues related to Angular testing features, such as TestBed label Apr 23, 2019
@ngbot ngbot bot added this to the needsTriage milestone Apr 23, 2019
@Goodwine Goodwine requested a review from a team as a code owner April 24, 2019 17:52
TestBed.get no longer returns `any`, and `TestBed.typedGet` is now
deprecated for Angular 9.x, It will eventually be removed,
`TestBed.typedGet` can be directly renamed to `TestBed.get`.

Fixes #26491

BREAKING CHANGE:

- TestBed.get has been replaced by TestBed.typedGet so now it returns
`T` instead of `any`. String providers are also no longer supported and
now InjectionToken can be used, otherwise cast to `any` and receive a
type `{}`. The untyped get was deprecated since 8.x

- Injector#get deprecated signature that takes `any` tokens and returns
`any` value has been removed, the signature was deprecated since 4.x
@Goodwine
Copy link
Author

After discussing with Vikram, I'm closing this for #32200

@Goodwine Goodwine closed this Aug 21, 2019
@Goodwine Goodwine deleted the breaking-typed-testbed-get branch August 21, 2019 18:23
@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 Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: testing Issues related to Angular testing features, such as TestBed cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants