angular-docs-cn/packages
Alex Rickabaugh d2742cf473 feat(ivy): compile @Injectable on classes not meant for DI (#28523)
In the past, @Injectable had no side effects and existing Angular code is
therefore littered with @Injectable usage on classes which are not intended
to be injected.

A common example is:

@Injectable()
class Foo {
  constructor(private notInjectable: string) {}
}

and somewhere else:

providers: [{provide: Foo, useFactory: ...})

Here, there is no need for Foo to be injectable - indeed, it's impossible
for the DI system to create an instance of it, as it has a non-injectable
constructor. The provider configures a factory for the DI system to be
able to create instances of Foo.

Adding @Injectable in Ivy signifies that the class's own constructor, and
not a provider, determines how the class will be created.

This commit adds logic to compile classes which are marked with @Injectable
but are otherwise not injectable, and create an ngInjectableDef field with
a factory function that throws an error. This way, existing code in the wild
continues to compile, but if someone attempts to use the injectable it will
fail with a useful error message.

In the case where strictInjectionParameters is set to true, a compile-time
error is thrown instead of the runtime error, as ngtsc has enough
information to determine when injection couldn't possibly be valid.

PR Close #28523
2019-02-13 19:13:10 -08:00
..
animations style: change to American English (#27266) 2019-01-29 16:30:25 -08:00
bazel build(bazel): update to rules_nodejs 0.18.6 (#28699) 2019-02-13 12:13:08 -08:00
benchpress feat: optionally save complete performance log in chrome benchpress tests (#27551) 2019-02-05 23:35:32 -05:00
common docs: add di-related api doc (#27731) 2019-02-13 11:57:37 -08:00
compiler feat(ivy): compile @Injectable on classes not meant for DI (#28523) 2019-02-13 19:13:10 -08:00
compiler-cli feat(ivy): compile @Injectable on classes not meant for DI (#28523) 2019-02-13 19:13:10 -08:00
core feat(ivy): compile @Injectable on classes not meant for DI (#28523) 2019-02-13 19:13:10 -08:00
docs refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
elements build: set a default module_name for ts_library rules (#28051) 2019-01-18 10:16:39 -08:00
examples fix(ivy): ngOnChanges should be inherited from super class (#28563) 2019-02-11 16:22:31 -08:00
forms build: run offline_compiler_test using bazel (#28191) 2019-01-28 20:07:22 -08:00
http build: run offline_compiler_test using bazel (#28191) 2019-01-28 20:07:22 -08:00
language-service fix(compiler): markup lexer should not capture quotes in attribute value (#28055) 2019-02-12 20:58:27 -08:00
platform-browser test(ivy): turn on passing test in platform-browser (#28604) 2019-02-07 16:46:34 -08:00
platform-browser-dynamic refactor(compiler): wrap the jit evaluation in an injectable class (#28055) 2019-02-12 20:58:27 -08:00
platform-server fix(ivy): throw on bindings to unknown properties (#28537) 2019-02-07 12:37:32 -08:00
platform-webworker fix(ivy): WorkerAppModule should be an APP_ROOT (#28544) 2019-02-06 14:05:53 -05:00
platform-webworker-dynamic build: set a default module_name for ts_library rules (#28051) 2019-01-18 10:16:39 -08:00
private/testing build: run playground e2e examples with bazel (#28490) 2019-02-04 16:51:11 -05:00
router refactor(router): change RouterLinkActive impl to account for upcoming ivy breaking change (#28560) 2019-02-08 16:42:45 -08:00
service-worker build: set a default module_name for ts_library rules (#28051) 2019-01-18 10:16:39 -08:00
upgrade test(upgrade): change flaky test to not be affected by other tests (#28617) 2019-02-08 09:27:02 -08:00
BUILD.bazel build(bazel): use fine-grained npm deps (#26111) (#26488) 2018-10-19 20:59:29 -07:00
README.md Revert "docs: Remove unneeded file (#18106)" 2017-07-20 16:46:47 -05:00
empty.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
goog.d.ts test(ivy): add bundling test `todo_i18n` (#27420) 2018-12-04 19:59:12 -08:00
license-banner.txt build: bump year (#27880) 2019-01-11 11:15:59 -08:00
rollup.config.js refactor: make all rollup config ES5 compatible (#20028) 2017-10-30 23:09:17 -04:00
system.d.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
tsconfig-build.json build(bazel): Turning on strictPropertyInitialization for Angular. (#24572) 2018-06-25 07:57:13 -07:00
tsconfig-test.json build: refactor ambient node & jasmine types so they are only included where needed (#25491) 2018-08-16 13:46:43 -07:00
tsconfig.json build: switch example e2e tests to bazel (#28402) 2019-01-28 19:21:09 -08:00
types.d.ts build: switch to typescript's es2015 typings (#28570) 2019-02-06 14:17:55 -05:00

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

License: MIT