Skip to content

fix(core): Deprecate TestBed.get(...):any - #29290

Closed
Goodwine wants to merge 1 commit into
angular:masterfrom
Goodwine:deprecate-testbed-get
Closed

Goodwine wants to merge 1 commit into
angular:masterfrom
Goodwine:deprecate-testbed-get

Conversation

@Goodwine

@Goodwine Goodwine commented Mar 13, 2019 •

Copy link
Copy Markdown

Adds an overload to TestBed.get making parameters strongly typed and
deprecated previous signature that accepted types any. The function
still returns any to prevent build breakages, but eventually stronger
type checks will be added so a future Angular version will break builds
due to additional type checks.
See previous breaking change - #13785

Issue #26491

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?

get(token: any, default?: any): any

Issue Number: #26491

What is the new behavior?

"Same" signature as Injector.get:

get(token: InjetionToken<T>|Type<T>, default?: T, flags?: InjectorFlags): any

(Instead of returning T, it still returns any) to prevent breaking changes for 8.0, but this will hopefully break on 9.0

Does this PR introduce a breaking change?

  • Yes
  • No

Note that the return type is still any, this will change to be an actual breaking change similar to #13785 in a future major version

Other information

@Goodwine
Goodwine requested review from a team March 13, 2019 23:28
@Goodwine

Copy link
Copy Markdown
Author

Note: At head these tests were already failing -

//packages/compiler-cli/test:extract_i18n
//packages/compiler-cli/test:ngc
//packages/compiler-cli/test:ngtools_api
//packages/compiler-cli/test:perform_compile
//packages/compiler-cli/test:perform_watch
//packages/compiler-cli/test/diagnostics:check_types
//packages/compiler-cli/test/diagnostics:expression_diagnostics
//packages/compiler-cli/test/transformers:test
//packages/core/test/bundling/cyclic_import:symbol_test
//packages/core/test/bundling/cyclic_import:test
//packages/core/test/bundling/hello_world:symbol_test
//packages/core/test/bundling/hello_world:test
//packages/core/test/bundling/todo:symbol_test
//packages/core/test/bundling/todo:test
//packages/core/test/bundling/todo_i18n:test
//packages/core/test/bundling/todo_r2:test
//packages/language-service/test:test

@mhevery mhevery self-assigned this Mar 19, 2019
@mhevery mhevery added the area: core Issues related to the framework runtime label Mar 19, 2019
@ngbot ngbot Bot added this to the needsTriage milestone Mar 19, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you reformat this? Can you revert?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed because 2 types were added (InjectFlags, InjectionToken) and the format script updated this "changed lines", a recent patch added clang-off so I guess it's not changing anymore (?)

Anyways, done :)

Adds an overload to TestBed.get making parameters strongly typed and
deprecated previous signature that accepted types `any`. The function
still returns `any` to prevent build breakages, but eventually stronger
type checks will be added so a future Angular version will break builds
due to additional type checks.
See previous breaking change - #13785

Issue #26491
@Goodwine

Goodwine commented Apr 3, 2019

Copy link
Copy Markdown
Author

@mhevery mhevery added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Apr 4, 2019
@IgorMinar IgorMinar closed this in 609024f Apr 4, 2019
@Goodwine
Goodwine deleted the deprecate-testbed-get branch April 4, 2019 22:36
wKoza pushed a commit to wKoza/angular that referenced this pull request Apr 17, 2019
Adds an overload to TestBed.get making parameters strongly typed and
deprecated previous signature that accepted types `any`. The function
still returns `any` to prevent build breakages, but eventually stronger
type checks will be added so a future Angular version will break builds
due to additional type checks.
See previous breaking change - angular#13785

Issue angular#26491

PR Close angular#29290
cexbrayat added a commit to cexbrayat/angular that referenced this pull request May 18, 2019
… overload

PR angular#29290 introduced a new `TestBed.get` signature and deprecated the existing one.
This raises a lot of TSLint deprecation warnings in projects using a strict TS config (see angular#29905 for context), so we are temporarily removing the `@deprecated` annotation in favor of a plain text warning until we properly fix it.

Refs angular#29905
Fixes FW-1336
jasonaden pushed a commit that referenced this pull request May 21, 2019
… overload (#30514)

PR #29290 introduced a new `TestBed.get` signature and deprecated the existing one.
This raises a lot of TSLint deprecation warnings in projects using a strict TS config (see #29905 for context), so we are temporarily removing the `@deprecated` annotation in favor of a plain text warning until we properly fix it.

Refs #29905
Fixes FW-1336

PR Close #30514
jasonaden pushed a commit that referenced this pull request May 21, 2019
… overload (#30514)

PR #29290 introduced a new `TestBed.get` signature and deprecated the existing one.
This raises a lot of TSLint deprecation warnings in projects using a strict TS config (see #29905 for context), so we are temporarily removing the `@deprecated` annotation in favor of a plain text warning until we properly fix it.

Refs #29905
Fixes FW-1336

PR Close #30514
@angular-automatic-lock-bot

Copy link
Copy Markdown

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 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants