99d8582882
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 |
||
---|---|---|
.buildkite | ||
.circleci | ||
.github | ||
.vscode | ||
aio | ||
docs | ||
integration | ||
modules | ||
packages | ||
scripts | ||
third_party | ||
tools | ||
.bazelignore | ||
.bazelrc | ||
.clang-format | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.mailmap | ||
.nvmrc | ||
BUILD.bazel | ||
CHANGELOG.md | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
LICENSE | ||
README.md | ||
WORKSPACE | ||
browser-providers.conf.js | ||
gulpfile.js | ||
index.bzl | ||
karma-js.conf.js | ||
package.json | ||
protractor-perf.conf.js | ||
shims_for_IE.js | ||
test-events.js | ||
test-main.js | ||
tslint.json | ||
yarn.lock | ||
yarn.lock.readme.md |
README.md
Angular
Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Quickstart
Changelog
Learn about the latest improvements.
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.