angular-cn/packages/compiler-cli
George Kalpakas 704775168d fix(ngcc): generate correct metadata for classes with getter/setter properties (#33514)
While processing class metadata, ngtsc generates a `setClassMetadata()`
call which (among other things) contains info about property decorators.
Previously, processing getter/setter pairs with some of ngcc's
`ReflectionHost`s resulted in multiple metadata entries for the same
property, which resulted in duplicate object keys, which in turn causes
an error in ES5 strict mode.

This commit fixes it by ensuring that there are no duplicate property
names in the `setClassMetadata()` calls.

In addition, `generateSetClassMetadataCall()` is updated to treat
`ClassMember#decorators: []` the same as `ClassMember.decorators: null`
(i.e. omitting the `ClassMember` from the generated `setClassMetadata()`
call). Alternatively, ngcc's `ReflectionHost`s could be updated to do
this transformation (`decorators: []` --> `decorators: null`) when
reflecting on class members, but this would require changes in many
places and be less future-proof.

For example, given a class such as:

```ts
class Foo {
  @Input() get bar() { return 'bar'; }
  set bar(value: any) {}
}
```

...previously the generated `setClassMetadata()` call would look like:

```ts
ɵsetClassMetadata(..., {
  bar: [{type: Input}],
  bar: [],
});
```

The same class will now result in a call like:

```ts
ɵsetClassMetadata(..., {
  bar: [{type: Input}],
});
```

Fixes #30569

PR Close #33514
2019-11-13 13:49:31 -08:00
..
integrationtest fix(core): support `ngInjectableDef` on types with inherited `ɵprov` (#33732) 2019-11-12 11:54:15 -08:00
ngcc fix(ngcc): generate correct metadata for classes with getter/setter properties (#33514) 2019-11-13 13:49:31 -08:00
src fix(ngcc): generate correct metadata for classes with getter/setter properties (#33514) 2019-11-13 13:49:31 -08:00
test refactor(compiler-cli): avoid superfluous parenthesis around statements (#33514) 2019-11-13 13:49:30 -08:00
BUILD.bazel build: fix build failures with worker mode cache and @types/events (#31325) 2019-07-01 14:16:43 -07:00
index.ts fix(compiler-cli): remove unused CLI private exports (#33242) 2019-11-01 17:43:47 +00:00
package.json build: set up all packages to publish via wombot proxy (#33747) 2019-11-13 11:34:33 -08:00
tsconfig-build.json build: reference zone.js from source directly instead of npm. (#33046) 2019-11-06 00:48:34 +00:00
tsconfig.json perf(ivy): ngcc - only find dependencies when targeting a single entry-point (#30525) 2019-07-09 09:40:46 -07:00