angular-docs-cn/packages/compiler-cli/test
Alex Rickabaugh 99d8582882 feat(ivy): support @Injectable on already decorated classes (#28523)
Previously, ngtsc would throw an error if two decorators were matched on
the same class simultaneously. However, @Injectable is a special case, and
it appears frequently on component, directive, and pipe classes. For pipes
in particular, it's a common pattern to treat the pipe class also as an
injectable service.

ngtsc actually lacked the capability to compile multiple matching
decorators on a class, so this commit adds support for that. Decorator
handlers (and thus the decorators they match) are classified into three
categories: PRIMARY, SHARED, and WEAK.

PRIMARY handlers compile decorators that cannot coexist with other primary
decorators. The handlers for Component, Directive, Pipe, and NgModule are
marked as PRIMARY. A class may only have one decorator from this group.

SHARED handlers compile decorators that can coexist with others. Injectable
is the only decorator in this category, meaning it's valid to put an
@Injectable decorator on a previously decorated class.

WEAK handlers behave like SHARED, but are dropped if any non-WEAK handler
matches a class. The handler which compiles ngBaseDef is WEAK, since
ngBaseDef is only needed if a class doesn't otherwise have a decorator.

Tests are added to validate that @Injectable can coexist with the other
decorators and that an error is generated when mixing the primaries.

PR Close #28523
2019-02-13 19:13:10 -08:00
..
compliance refactor(ivy): combine contentQueries and contentQueriesRefresh functions (#28503) 2019-02-13 12:01:32 -08:00
diagnostics refactor(compiler): use `options` argument for parsers (#28055) 2019-02-12 20:58:27 -08:00
metadata test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags (#26471) 2018-10-23 08:57:42 -07:00
ngcc build: support running compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
ngtsc feat(ivy): support @Injectable on already decorated classes (#28523) 2019-02-13 19:13:10 -08:00
transformers build: fix failing compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
BUILD.bazel build: support running compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
extract_i18n_spec.ts build: remove unused "test.sh" leftover code in compiler-cli (#28352) 2019-02-05 14:31:10 -05:00
mocks.ts fix(compiler-cli): Use typescript to resolve modules for metadata (#22856) 2018-07-10 11:11:48 -07:00
ngc_spec.ts feat(compiler-cli): no longer re-export external symbols by default (#28633) 2019-02-13 09:49:51 -08:00
ngtools_api_spec.ts fix(ivy): support listing lazy route for project-root-relative entry point in `ngtsc` (#28542) 2019-02-11 16:23:30 -08:00
perform_compile_spec.ts feat(compiler-cli): add support to extend `angularCompilerOptions` (#22717) 2018-09-19 16:17:28 -07:00
perform_watch_spec.ts build: fix failing compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
runfile_helpers.ts build: support running compiler-cli tests on windows (#28352) 2019-02-05 14:31:10 -05:00
test_support.ts test(ivy): test listing lazy routes to different root directories (#28542) 2019-02-11 16:23:30 -08:00