4055150910
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 |
||
---|---|---|
.. | ||
animations | ||
bazel | ||
benchpress | ||
common | ||
compiler | ||
compiler-cli | ||
core | ||
docs | ||
elements | ||
examples | ||
forms | ||
http | ||
language-service | ||
platform-browser | ||
platform-browser-dynamic | ||
platform-server | ||
platform-webworker | ||
platform-webworker-dynamic | ||
private/testing | ||
router | ||
service-worker | ||
upgrade | ||
zone.js | ||
BUILD.bazel | ||
README.md | ||
empty.ts | ||
goog.d.ts | ||
license-banner.txt | ||
system.d.ts | ||
tsconfig-build-no-strict.json | ||
tsconfig-build.json | ||
tsconfig-test.json | ||
tsconfig.json | ||
types.d.ts |
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