angular-cn/tools/public_api_guard
Alex Rickabaugh f90c7a9df0 feat(compiler): allow selector-less directives as base classes (#31379)
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
2019-08-09 10:45:22 -07:00
..
animations docs: update animations to use `@publicApi` tags (#26595) 2018-10-19 14:35:53 -07:00
common build: TypeScript 3.5 upgrade (#31615) 2019-07-25 17:05:23 -07:00
core feat(compiler): allow selector-less directives as base classes (#31379) 2019-08-09 10:45:22 -07:00
elements docs: update elements to use `@publicApi` tags (#26595) 2018-10-19 14:35:53 -07:00
forms feat(forms): formControlName also accepts a number (#30606) 2019-08-09 10:39:22 -07:00
http docs(http): move examples to `@usageNotes` (#26039) 2018-09-24 09:11:02 -07:00
platform-browser fix(platform-browser): debug element query predicates not compatible with strictFunctionTypes (#30993) 2019-07-18 14:21:26 -07:00
platform-browser-dynamic docs: update platform-browser-dynamic to use `@publicApi` tags (#26595) 2018-10-19 14:35:53 -07:00
platform-server docs: update platform-server to use `@publicApi` tags (#26595) 2018-10-19 14:35:53 -07:00
platform-webworker feat(platform-webworker): deprecate platform-webworker (#30642) 2019-05-23 15:09:48 -07:00
platform-webworker-dynamic feat(platform-webworker): deprecate platform-webworker (#30642) 2019-05-23 15:09:48 -07:00
router docs: clean up router api doc (#31476) 2019-07-18 10:33:17 -07:00
service-worker refactor(service-worker): DRY up SW registration logic (#21842) 2019-04-25 12:29:58 -07:00
upgrade feat(upgrade): provide unit test helpers for wiring up injectors (#16848) 2019-06-20 17:04:01 -07:00
BUILD.bazel refactor(upgrade): use Bazel packages to avoid symlinks in the source (#29466) 2019-04-02 10:38:01 -07:00
global_utils.d.ts refactor(ivy): remove all old styling code prior to refactor (#31193) 2019-07-23 15:45:32 -07:00
public_api_guard.bzl build(ivy): remove the remains of ivy-jit mode (#27278) 2018-11-27 10:30:58 -08:00