f90c7a9df0
In Angular today, the following pattern works: ```typescript export class BaseDir { constructor(@Inject(ViewContainerRef) protected vcr: ViewContainerRef) {} } @Directive({ selector: '[child]', }) export class ChildDir extends BaseDir { // constructor inherited from BaseDir } ``` A decorated child class can inherit a constructor from an undecorated base class, so long as the base class has metadata of its own (for JIT mode). This pattern works regardless of metadata in AOT. In Angular Ivy, this pattern does not work: without the @Directive annotation identifying the base class as a directive, information about its constructor parameters will not be captured by the Ivy compiler. This is a result of Ivy's locality principle, which is the basis behind a number of compilation optimizations. As a solution, @Directive() without a selector will be interpreted as a "directive base class" annotation. Such a directive cannot be declared in an NgModule, but can be inherited from. To implement this, a few changes are made to the ngc compiler: * the error for a selector-less directive is now generated when an NgModule declaring it is processed, not when the directive itself is processed. * selector-less directives are not tracked along with other directives in the compiler, preventing other errors (like their absence in an NgModule) from being generated from them. PR Close #31379 |
||
---|---|---|
.circleci | ||
.codefresh | ||
.devcontainer | ||
.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 | ||
browser_repositories.bzl | ||
gulpfile.js | ||
karma-js.conf.js | ||
package.json | ||
protractor-perf.conf.js | ||
renovate.json | ||
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.