704775168d
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 |
||
---|---|---|
.. | ||
src | ||
test | ||
BUILD.bazel | ||
README.md | ||
index.ts | ||
main-ivy-ngcc.ts | ||
main-ngcc.ts |
README.md
Angular Compatibility Compiler (ngcc)
This compiler will convert node_modules
compiled with ngc
, into node_modules
which
appear to have been compiled with ngtsc
.
This conversion will allow such "legacy" packages to be used by the Ivy rendering engine.
Building
The project is built using Bazel:
yarn bazel build //packages/compiler-cli/ngcc
Unit Testing
The unit tests are built and run using Bazel:
yarn bazel test //packages/compiler-cli/ngcc/test
Integration Testing
There are tests that check the behavior of the overall executable:
yarn bazel test //packages/compiler-cli/ngcc/test:integration