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

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

Goodwine
Copy link
Contributor

@Goodwine Goodwine commented Mar 13, 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 - #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 as code owners Mar 13, 2019
@Goodwine
Copy link
Contributor Author

@Goodwine Goodwine commented Mar 13, 2019

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
@ngbot ngbot bot added this to the needsTriage milestone Mar 19, 2019
// clang-format on
import {ResourceLoader} from '@angular/compiler';
import {ApplicationInitStatus, COMPILER_OPTIONS, Compiler, CompilerOptions, Component, Directive, ErrorHandler, InjectFlags, InjectionToken, Injector, ModuleWithComponentFactories, NgModule, NgModuleFactory, NgZone, Pipe, PlatformRef, Provider, SchemaMetadata, StaticProvider, Type, resolveForwardRef, ɵInjectableDef as InjectableDef, ɵNG_COMPONENT_DEF as NG_COMPONENT_DEF, ɵNG_DIRECTIVE_DEF as NG_DIRECTIVE_DEF, ɵNG_INJECTOR_DEF as NG_INJECTOR_DEF, ɵNG_MODULE_DEF as NG_MODULE_DEF, ɵNG_PIPE_DEF as NG_PIPE_DEF, ɵNgModuleDef as NgModuleDef, ɵNgModuleFactory as R3NgModuleFactory, ɵNgModuleType as NgModuleType, ɵRender3ComponentFactory as ComponentFactory, ɵRender3NgModuleRef as NgModuleRef, ɵcompileComponent as compileComponent, ɵcompileDirective as compileDirective, ɵcompileNgModuleDefs as compileNgModuleDefs, ɵcompilePipe as compilePipe, ɵflushModuleScopingQueueAsMuchAsPossible as flushModuleScopingQueueAsMuchAsPossible, ɵgetInjectableDef as getInjectableDef, ɵpatchComponentDefWithScope as patchComponentDefWithScope, ɵresetCompiledComponents as resetCompiledComponents, ɵstringify as stringify, ɵtransitiveScopesFor as transitiveScopesFor} from '@angular/core';
Copy link
Contributor

@mhevery mhevery Mar 21, 2019

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
Contributor Author

@Goodwine Goodwine Apr 3, 2019

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
Copy link
Contributor Author

@Goodwine Goodwine commented Apr 3, 2019

mhevery
mhevery approved these changes Apr 4, 2019
@Goodwine Goodwine deleted the deprecate-testbed-get branch Apr 4, 2019
DeveloperFromUkraine added a commit to DeveloperFromUkraine/angular that referenced this issue Apr 11, 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
wKoza added a commit to wKoza/angular that referenced this issue 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 issue May 16, 2019
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.

Fixes angular#29905
Fixes FW-1336
cexbrayat added a commit to cexbrayat/angular that referenced this issue May 16, 2019
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.

Fixes angular#29905
Fixes FW-1336
cexbrayat added a commit to cexbrayat/angular that referenced this issue May 17, 2019
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.

Fixes angular#29905
Fixes FW-1336
cexbrayat added a commit to cexbrayat/angular that referenced this issue 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 added a commit that referenced this issue 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 added a commit that referenced this issue 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

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Sep 14, 2019

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.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants