angular-cn/modules/@angular/core/test
Miško Hevery d169c2434e feat(core): Add type information to injector.get() (#13785)
- Introduce `InjectionToken<T>` which is a parameterized and type-safe
  version of `OpaqueToken`.

DEPRECATION:
- `OpaqueToken` is now deprecated, use `InjectionToken<T>` instead.
- `Injector.get(token: any, notFoundValue?: any): any` is now deprecated
  use the same method which is now overloaded as
  `Injector.get<T>(token: Type<T>|InjectionToken<T>, notFoundValue?: T): T;`.

Migration
- Replace `OpaqueToken` with `InjectionToken<?>` and parameterize it.
- Migrate your code to only use `Type<?>` or `InjectionToken<?>` as
  injection tokens. Using other tokens will not be supported in the
  future.

BREAKING CHANGE:
- Because `injector.get()` is now parameterize it is possible that code
  which used to work no longer type checks. Example would be if one
  injects `Foo` but configures it as `{provide: Foo, useClass: MockFoo}`.
  The injection instance will be that of `MockFoo` but the type will be
  `Foo` instead of `any` as in the past. This means that it was possible
  to call a method on `MockFoo` in the past which now will fail type
  check. See this example:

```
class Foo {}
class MockFoo extends Foo {
  setupMock();
}

var PROVIDERS = [
  {provide: Foo, useClass: MockFoo}
];

...

function myTest(injector: Injector) {
  var foo = injector.get(Foo);
  // This line used to work since `foo` used to be `any` before this
  // change, it will now be `Foo`, and `Foo` does not have `setUpMock()`.
  // The fix is to downcast: `injector.get(Foo) as MockFoo`.
  foo.setUpMock();
}
```

PR Close #13785
2017-01-17 15:34:54 -06:00
..
animation feat(animations): support function types in transitions 2017-01-06 19:29:46 -05:00
change_detection fix(core): Add type information to differs 2017-01-09 18:56:34 -05:00
debug refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
di refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
dom refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
facade refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
linker feat(core): Add type information to injector.get() (#13785) 2017-01-17 15:34:54 -06:00
metadata refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
reflection fix(compiler): don’t throw when using `ANALYZE_FOR_ENTRY_COMPONENTS` with user classes (#13679) 2016-12-27 16:58:52 -08:00
testability refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
util feat(core): properly support inheritance 2016-11-28 14:12:12 -08:00
zone refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
application_init_spec.ts Typo (#13698) 2016-12-29 09:41:21 -08:00
application_module_spec.ts fix(common): do not override locale provided on bootstrap (#13654) 2017-01-05 09:24:37 -08:00
application_ref_spec.ts fix(core): properly destroy embedded Views attatched to ApplicationRef (#13459) 2016-12-14 08:33:29 -08:00
component_fixture_spec.ts refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
dev_mode_spec.ts fix(testing): remove deprecated testing APIs (#9923) 2016-07-11 16:04:32 -07:00
directive_lifecycle_integration_spec.ts refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
error_handler_spec.ts refactor(): use const and let instead of var 2016-11-12 16:40:17 -08:00
fake_async_spec.ts feat: upgrade zone.js to v0.7.1 2016-11-29 17:24:00 -08:00
forward_ref_integration_spec.ts fix(DomSchemaRegistry): detect invalid elements 2016-08-30 21:32:03 -07:00
spies.ts chore(lint): Added license headers to most TypeScript files 2016-06-23 09:47:54 -07:00
testing_internal_spec.ts refactor: kill MapWrapper 2016-11-04 13:27:38 -07:00